Don't allow bridging conversions when we're processing favored constraints.

This is another instance where we choose a favored constraint that
only type checks because we're bridging through NSNumber, causing
awful problems. Fixes rdar://problem/17962491.


Swift SVN r21445
This commit is contained in:
Doug Gregor
2014-08-25 22:16:58 +00:00
parent b3f6219ebe
commit 16d8294814
7 changed files with 76 additions and 3 deletions

View File

@@ -1675,7 +1675,8 @@ ConstraintSystem::matchTypes(Type type1, Type type2, TypeMatchKind kind,
TC.Context.Id_CVarArgType;
}
if (isBridgeableTargetType && TC.getBridgedToObjC(DC, type1)) {
if (isBridgeableTargetType && TC.getBridgedToObjC(DC, type1) &&
!HandlingFavoredConstraint) {
conversionsOrFixes.push_back(ConversionRestrictionKind::BridgeToObjC);
}
}
@@ -1686,7 +1687,8 @@ ConstraintSystem::matchTypes(Type type1, Type type2, TypeMatchKind kind,
if (type1->mayHaveSuperclass() && type2->isPotentiallyBridgedValueType() &&
type2->getAnyNominal()
!= TC.Context.getImplicitlyUnwrappedOptionalDecl() &&
TC.getBridgedToObjC(DC, type2)) {
TC.getBridgedToObjC(DC, type2) &&
!HandlingFavoredConstraint) {
conversionsOrFixes.push_back(ConversionRestrictionKind::BridgeFromObjC);
}