@@ -1354,7 +1354,7 @@ ConstraintSystem::matchTupleTypes(TupleType *tuple1, TupleType *tuple2,
1354
1354
static bool matchFunctionRepresentations (FunctionTypeRepresentation rep1,
1355
1355
FunctionTypeRepresentation rep2,
1356
1356
ConstraintKind kind,
1357
- ConstraintLocator * locator) {
1357
+ ConstraintLocatorBuilder locator) {
1358
1358
switch (kind) {
1359
1359
case ConstraintKind::Bind:
1360
1360
case ConstraintKind::BindParam:
@@ -1363,25 +1363,14 @@ static bool matchFunctionRepresentations(FunctionTypeRepresentation rep1,
1363
1363
return rep1 != rep2;
1364
1364
1365
1365
case ConstraintKind::Subtype: {
1366
- if (!locator->isLastElement <LocatorPathElt::FunctionArgument>())
1367
- return false ;
1368
-
1369
- auto isThin = [](FunctionTypeRepresentation rep) {
1370
- return rep == FunctionTypeRepresentation::CFunctionPointer ||
1371
- rep == FunctionTypeRepresentation::Thin;
1372
- };
1373
-
1374
- auto isThick = [](FunctionTypeRepresentation rep) {
1375
- return rep == FunctionTypeRepresentation::Swift ||
1376
- rep == swift::FunctionTypeRepresentation::Block;
1377
- };
1378
-
1379
- // Allowing conventions "thin" (c, thin) to "thick" (swift, block)
1380
- if (isThin (rep1) && isThick (rep2))
1366
+ auto last = locator.last ();
1367
+ if (!(last && last->is <LocatorPathElt::FunctionArgument>()))
1381
1368
return false ;
1382
1369
1383
- // Allowing conventions "thick" (swift, block) to "thick" (swift, block)
1384
- if (isThick (rep1) && isThick (rep2))
1370
+ // Allowing all to "thick" (swift, block) conventions
1371
+ // "thin" (c, thin) to "thick" or "thick" to "thick"
1372
+ if (rep2 == FunctionTypeRepresentation::Swift ||
1373
+ rep2 == FunctionTypeRepresentation::Block)
1385
1374
return false ;
1386
1375
1387
1376
return rep1 != rep2;
@@ -1682,7 +1671,7 @@ ConstraintSystem::matchFunctionTypes(FunctionType *func1, FunctionType *func2,
1682
1671
1683
1672
if (matchFunctionRepresentations (func1->getExtInfo ().getRepresentation (),
1684
1673
func2->getExtInfo ().getRepresentation (),
1685
- kind, getConstraintLocator ( locator) )) {
1674
+ kind, locator)) {
1686
1675
return getTypeMatchFailure (locator);
1687
1676
}
1688
1677
0 commit comments