Skip to content

Commit cc98458

Browse files
committed
[noescape-by-default] incorporate Doug's feedback
Added sugared test case
1 parent 224613a commit cc98458

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/Sema/CSDiag.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3614,7 +3614,7 @@ static bool tryDiagnoseNonEscapingParameterToEscaping(Expr *expr, Type srcType,
36143614
return false;
36153615

36163616
// Function types must be equivalent modulo @escaping, @convention, etc.
3617-
if (destFT != srcFT->withExtInfo(destFT->getExtInfo()))
3617+
if (!destFT->isEqual(srcFT->withExtInfo(destFT->getExtInfo())))
36183618
return false;
36193619

36203620
// Pick a specific diagnostic for the specific use

test/attr/attr_escaping.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ func callEscapingWithNoEscape(_ fn: () -> Int) {
1616
let _ = fn // expected-error{{non-escaping parameter 'fn' may only be called}}
1717
}
1818

19+
typealias IntSugar = Int
20+
func callSugared(_ fn: () -> IntSugar) {
21+
// expected-note@-1{{parameter 'fn' is implicitly non-escaping}} {{24-24=@escaping }}
22+
23+
takesEscaping(fn) // expected-error{{passing non-escaping parameter 'fn' to function expecting an @escaping closure}}
24+
}
1925

2026
struct StoresClosure {
2127
var closure : () -> Int

0 commit comments

Comments
 (0)