File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -398,6 +398,14 @@ ValueDecl *RequirementFailure::getDeclRef() const {
398
398
}
399
399
}
400
400
401
+ if (auto *closure = getAsExpr<ClosureExpr>(getRawAnchor ())) {
402
+ if (auto argElt =
403
+ getLocator ()->getFirstElementAs <LocatorPathElt::TupleElement>()) {
404
+ auto *param = (*closure->getParameters ())[argElt->getIndex ()];
405
+ return getAffectedDeclFromType (getType (param));
406
+ }
407
+ }
408
+
401
409
return getAffectedDeclFromType (getOwnerType ());
402
410
}
403
411
Original file line number Diff line number Diff line change @@ -1366,3 +1366,29 @@ do {
1366
1366
try $0. missing // expected-error {{value of type 'Int' has no member 'missing'}}
1367
1367
}
1368
1368
}
1369
+
1370
+ // Generic requirement failures associated with closure parameters should be diagnosed.
1371
+ protocol Input {
1372
+ associatedtype Value
1373
+ var value : Value { get }
1374
+ }
1375
+
1376
+ protocol Idable {
1377
+ associatedtype ID
1378
+ }
1379
+
1380
+ struct TestInput < ItemID: Hashable , Value: Collection < ItemID > > : Input { // expected-note {{where 'Value' = 'Item.ID'}}
1381
+ var value : Value
1382
+ }
1383
+
1384
+ struct Container < I: Input > {
1385
+ var data : ( I ) -> Void
1386
+ }
1387
+
1388
+ func test_generic_closure_parameter_requirement_failure< Item: Idable > (
1389
+ for itemType: Item . Type = Item . self,
1390
+ _ payload: @escaping ( _ itemID: Item . ID ) -> Void
1391
+ ) where Item. ID : Sendable {
1392
+ Container ( data: { ( input: TestInput ) in payload ( input. value) } )
1393
+ // expected-error@-1 {{generic struct 'TestInput' requires that 'Item.ID' conform to 'Collection'}}
1394
+ }
You can’t perform that action at this time.
0 commit comments