[ConstraintSystem] Don't allow explicit closure result to be implicitly converted to Void

It's allowed to convert a single statement closure from `(...) -> T` to `(...) -> Void`
_only_ if there is no explicit `return` in the body.

Resolves: [SR-12277](https://bugs.swift.org/browse/SR-12277)
Resolves: rdar://problem/52204414
This commit is contained in:
Pavel Yaskevich
2020-03-19 16:51:50 -07:00
parent 0ebdba06b5
commit 89933c67da
5 changed files with 37 additions and 9 deletions

View File

@@ -3434,6 +3434,7 @@ void constraints::simplifyLocator(Expr *&anchor,
}
break;
case ConstraintLocator::ClosureBody:
case ConstraintLocator::ClosureResult:
if (auto CE = dyn_cast<ClosureExpr>(anchor)) {
if (CE->hasSingleExpressionBody()) {