@@ -1349,27 +1349,27 @@ 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 .
1352
+ // Determine whether conversion is allowed between two function types
1353
+ // based on their representations .
1354
1354
static bool
1355
- matchFunctionConversionRepresentations (FunctionTypeRepresentation rep1,
1356
- FunctionTypeRepresentation rep2) {
1355
+ isConversionAllowedBetween (FunctionTypeRepresentation rep1,
1356
+ FunctionTypeRepresentation rep2) {
1357
1357
auto isThin = [](FunctionTypeRepresentation rep) {
1358
1358
return rep == FunctionTypeRepresentation::CFunctionPointer ||
1359
1359
rep == FunctionTypeRepresentation::Thin;
1360
1360
};
1361
1361
1362
1362
// Allowing "thin" (c, thin) to "thin" conventions
1363
1363
if (isThin (rep1) && isThin (rep2))
1364
- return false ;
1364
+ return true ;
1365
1365
1366
1366
// Allowing all to "thick" (swift, block) conventions
1367
1367
// "thin" (c, thin) to "thick" or "thick" to "thick"
1368
1368
if (rep2 == FunctionTypeRepresentation::Swift ||
1369
1369
rep2 == FunctionTypeRepresentation::Block)
1370
- return false ;
1370
+ return true ;
1371
1371
1372
- return rep1 ! = rep2;
1372
+ return rep1 = = rep2;
1373
1373
}
1374
1374
1375
1375
// Returns 'false' (i.e. no error) if it is legal to match functions with the
@@ -1390,7 +1390,9 @@ static bool matchFunctionRepresentations(FunctionTypeRepresentation rep1,
1390
1390
if (!(last && last->is <LocatorPathElt::FunctionArgument>()))
1391
1391
return false ;
1392
1392
1393
- return matchFunctionConversionRepresentations (rep1, rep2);
1393
+ // Inverting the result because matchFunctionRepresentations
1394
+ // returns false in conversions are allowed.
1395
+ return !isConversionAllowedBetween (rep1, rep2);
1394
1396
}
1395
1397
1396
1398
case ConstraintKind::OpaqueUnderlyingType:
0 commit comments