@@ -1558,8 +1558,7 @@ isConversionAllowedBetween(FunctionTypeRepresentation rep1,
1558
1558
return rep1 == rep2;
1559
1559
}
1560
1560
1561
- // Returns 'false' (i.e. no error) if it is legal to match functions with the
1562
- // corresponding function type representations and the given match kind.
1561
+ // / Returns true if `constraint rep1 rep2` is satisfied.
1563
1562
static bool matchFunctionRepresentations (FunctionTypeRepresentation rep1,
1564
1563
FunctionTypeRepresentation rep2,
1565
1564
ConstraintKind kind,
@@ -1569,16 +1568,14 @@ static bool matchFunctionRepresentations(FunctionTypeRepresentation rep1,
1569
1568
case ConstraintKind::BindParam:
1570
1569
case ConstraintKind::BindToPointerType:
1571
1570
case ConstraintKind::Equal:
1572
- return rep1 ! = rep2;
1571
+ return rep1 = = rep2;
1573
1572
1574
1573
case ConstraintKind::Subtype: {
1575
1574
auto last = locator.last ();
1576
1575
if (!(last && last->is <LocatorPathElt::FunctionArgument>()))
1577
- return false ;
1578
-
1579
- // Inverting the result because matchFunctionRepresentations
1580
- // returns false in conversions are allowed.
1581
- return !isConversionAllowedBetween (rep1, rep2);
1576
+ return true ;
1577
+
1578
+ return isConversionAllowedBetween (rep1, rep2);
1582
1579
}
1583
1580
1584
1581
case ConstraintKind::OpaqueUnderlyingType:
@@ -1609,7 +1606,7 @@ static bool matchFunctionRepresentations(FunctionTypeRepresentation rep1,
1609
1606
case ConstraintKind::OneWayEqual:
1610
1607
case ConstraintKind::OneWayBindParam:
1611
1608
case ConstraintKind::DefaultClosureType:
1612
- return false ;
1609
+ return true ;
1613
1610
}
1614
1611
1615
1612
llvm_unreachable (" Unhandled ConstraintKind in switch." );
@@ -1902,9 +1899,9 @@ ConstraintSystem::matchFunctionTypes(FunctionType *func1, FunctionType *func2,
1902
1899
return getTypeMatchFailure (locator);
1903
1900
}
1904
1901
1905
- if (matchFunctionRepresentations (func1->getExtInfo ().getRepresentation (),
1906
- func2->getExtInfo ().getRepresentation (),
1907
- kind, locator)) {
1902
+ if (! matchFunctionRepresentations (func1->getExtInfo ().getRepresentation (),
1903
+ func2->getExtInfo ().getRepresentation (),
1904
+ kind, locator)) {
1908
1905
return getTypeMatchFailure (locator);
1909
1906
}
1910
1907
0 commit comments