File tree Expand file tree Collapse file tree 2 files changed +43
-1
lines changed Expand file tree Collapse file tree 2 files changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -1399,7 +1399,18 @@ void PotentialBindings::infer(Constraint *constraint) {
1399
1399
}
1400
1400
1401
1401
case ConstraintKind::ApplicableFunction:
1402
- case ConstraintKind::DynamicCallableApplicableFunction:
1402
+ case ConstraintKind::DynamicCallableApplicableFunction: {
1403
+ auto overloadTy = constraint->getSecondType ();
1404
+ // If current type variable represents an overload set
1405
+ // being applied to the arguments, it can't be delayed
1406
+ // by application constraints, because it doesn't
1407
+ // depend on argument/result types being resolved first.
1408
+ if (overloadTy->isEqual (TypeVar))
1409
+ break ;
1410
+
1411
+ LLVM_FALLTHROUGH;
1412
+ }
1413
+
1403
1414
case ConstraintKind::BindOverload: {
1404
1415
DelayedBy.push_back (constraint);
1405
1416
break ;
Original file line number Diff line number Diff line change @@ -1132,3 +1132,34 @@ func rdar76058892() {
1132
1132
}
1133
1133
}
1134
1134
}
1135
+
1136
+ // rdar://78917861 - Invalid generic type parameter inference
1137
+
1138
+ func rdar78917861( ) {
1139
+ class Cell { }
1140
+ class MyCell : Cell { }
1141
+
1142
+ class DataCollection < D, C: Cell > {
1143
+ }
1144
+
1145
+ class MyCollection {
1146
+ typealias DataType = String
1147
+ typealias CellType = MyCell
1148
+
1149
+ var data : DataCollection < DataType , CellType >
1150
+
1151
+ init ( ) {
1152
+ self . data = DataCollection < DataType , CellType > ( )
1153
+ }
1154
+ }
1155
+
1156
+ class Test {
1157
+ let collection = MyCollection ( )
1158
+
1159
+ lazy var prop : DataCollection = {
1160
+ collection. data // Ok
1161
+ // Since contextual type `DataCollection` doesn't specify generic parameters they have to be inferred
1162
+ // but that has to wait until the closure is resolved because types can flow both ways
1163
+ } ( )
1164
+ }
1165
+ }
You can’t perform that action at this time.
0 commit comments