@@ -1349,6 +1349,29 @@ ConstraintSystem::matchTupleTypes(TupleType *tuple1, TupleType *tuple2,
1349
1349
return getTypeMatchSuccess ();
1350
1350
}
1351
1351
1352
+ // Determine if a function representation conversion is allowed returning
1353
+ // 'false' (i.e. no error) if the conversion is valid.
1354
+ static bool
1355
+ matchFunctionConversionRepresentations (FunctionTypeRepresentation rep1,
1356
+ FunctionTypeRepresentation rep2) {
1357
+ auto isThin = [](FunctionTypeRepresentation rep) {
1358
+ return rep == FunctionTypeRepresentation::CFunctionPointer ||
1359
+ rep == FunctionTypeRepresentation::Thin;
1360
+ };
1361
+
1362
+ // Allowing "thin" (c, thin) to "thin" conventions
1363
+ if (isThin (rep1) && isThin (rep2))
1364
+ return false ;
1365
+
1366
+ // Allowing all to "thick" (swift, block) conventions
1367
+ // "thin" (c, thin) to "thick" or "thick" to "thick"
1368
+ if (rep2 == FunctionTypeRepresentation::Swift ||
1369
+ rep2 == FunctionTypeRepresentation::Block)
1370
+ return false ;
1371
+
1372
+ return rep1 != rep2;
1373
+ }
1374
+
1352
1375
// Returns 'false' (i.e. no error) if it is legal to match functions with the
1353
1376
// corresponding function type representations and the given match kind.
1354
1377
static bool matchFunctionRepresentations (FunctionTypeRepresentation rep1,
@@ -1367,22 +1390,7 @@ static bool matchFunctionRepresentations(FunctionTypeRepresentation rep1,
1367
1390
if (!(last && last->is <LocatorPathElt::FunctionArgument>()))
1368
1391
return false ;
1369
1392
1370
- auto isThin = [](FunctionTypeRepresentation rep) {
1371
- return rep == FunctionTypeRepresentation::CFunctionPointer ||
1372
- rep == FunctionTypeRepresentation::Thin;
1373
- };
1374
-
1375
- // Allowing "thin" (c, thin) to "thin" conventions
1376
- if (isThin (rep1) && isThin (rep2))
1377
- return false ;
1378
-
1379
- // Allowing all to "thick" (swift, block) conventions
1380
- // "thin" (c, thin) to "thick" or "thick" to "thick"
1381
- if (rep2 == FunctionTypeRepresentation::Swift ||
1382
- rep2 == FunctionTypeRepresentation::Block)
1383
- return false ;
1384
-
1385
- return rep1 != rep2;
1393
+ return matchFunctionConversionRepresentations (rep1, rep2);
1386
1394
}
1387
1395
1388
1396
case ConstraintKind::OpaqueUnderlyingType:
0 commit comments