flatMap on UIView.constraints type inference confusion with no return type change in closure

This behavior occurs because:

If a closure contains a single expression, Swift will consider its body in addition to its signature and the surrounding context when performing type inference. [...] If a closure body is not a single expression, it will not be considered when inferring the closure type.

The reason for this is as follows:

See the compiler's educational note for closure type inference for more information on how to address this situation in your code.