File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -2404,7 +2404,7 @@ namespace {
2404
2404
CS.getConstraintLocator (expr, ConstraintLocator::ClosureResult);
2405
2405
2406
2406
if (expr->hasEmptyBody ()) {
2407
- resultTy = CS.createTypeVariable (locator, TVO_CanBindToNoEscape );
2407
+ resultTy = CS.createTypeVariable (locator, 0 );
2408
2408
2409
2409
// Closures with empty bodies should be inferred to return
2410
2410
// ().
@@ -2416,7 +2416,7 @@ namespace {
2416
2416
} else {
2417
2417
// If no return type was specified, create a fresh type
2418
2418
// variable for it.
2419
- resultTy = CS.createTypeVariable (locator, TVO_CanBindToNoEscape );
2419
+ resultTy = CS.createTypeVariable (locator, 0 );
2420
2420
2421
2421
if (closureHasNoResult (expr)) {
2422
2422
// Allow it to default to () if there are no return statements.
Original file line number Diff line number Diff line change @@ -899,3 +899,10 @@ do {
899
899
}
900
900
}
901
901
}
902
+
903
+ // Don't allow result type of a closure to end up as a noescape type
904
+
905
+ // The funny error is because we infer the type of badResult as () -> ()
906
+ // via the 'T -> U => T -> ()' implicit conversion.
907
+ let badResult = { ( fn: ( ) -> ( ) ) in fn }
908
+ // expected-error@-1 {{expression resolves to an unused function}}
You can’t perform that action at this time.
0 commit comments