File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -409,6 +409,12 @@ ConstraintLocator *ConstraintSystem::getConstraintLocator(
409
409
}
410
410
411
411
ConstraintLocator *ConstraintSystem::getCalleeLocator (Expr *expr) {
412
+ // Make sure we handle subscripts before looking at apply exprs. We don't
413
+ // want to return a subscript member locator for an expression such as x[](y),
414
+ // as its callee is not the subscript, but rather the function it returns.
415
+ if (isa<SubscriptExpr>(expr))
416
+ return getConstraintLocator (expr, ConstraintLocator::SubscriptMember);
417
+
412
418
if (auto *applyExpr = dyn_cast<ApplyExpr>(expr)) {
413
419
auto *fnExpr = applyExpr->getFn ();
414
420
// For an apply of a metatype, we have a short-form constructor. Unlike
@@ -437,9 +443,6 @@ ConstraintLocator *ConstraintSystem::getCalleeLocator(Expr *expr) {
437
443
if (isa<UnresolvedMemberExpr>(expr))
438
444
return getConstraintLocator (locator, ConstraintLocator::UnresolvedMember);
439
445
440
- if (isa<SubscriptExpr>(expr))
441
- return getConstraintLocator (locator, ConstraintLocator::SubscriptMember);
442
-
443
446
if (isa<MemberRefExpr>(expr))
444
447
return getConstraintLocator (locator, ConstraintLocator::Member);
445
448
Original file line number Diff line number Diff line change @@ -109,8 +109,11 @@ func foo(block: () -> (), other: () -> Int) {
109
109
110
110
struct S {
111
111
init < T> ( _ x: T , _ y: T ) { } // expected-note {{generic parameters are always considered '@escaping'}}
112
- init ( fn: ( ) -> Int ) {
112
+ subscript< T> ( ) -> ( T , T ) -> Void { { _, _ in } }
113
+
114
+ init ( fn: ( ) -> Int ) { // expected-note {{parameter 'fn' is implicitly non-escaping}}
113
115
self . init ( { 0 } , fn) // expected-error {{converting non-escaping parameter 'fn' to generic parameter 'T' may allow it to escape}}
116
+ _ = self [ ] ( { 0 } , fn) // expected-error {{passing non-escaping parameter 'fn' to function expecting an @escaping closure}}
114
117
}
115
118
}
116
119
You can’t perform that action at this time.
0 commit comments