mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Support implicit conversions from AnyObject to String, if NSString is available as a bridging type. This addresses rdar://problem/16271835, rdar://problem/15257126 and rdar://problem/15288553.
Swift SVN r16834
This commit is contained in:
@@ -1156,7 +1156,23 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyConformsToConstraint(
|
||||
if (TC.conformsToProtocol(type, protocol, DC))
|
||||
return SolutionKind::Solved;
|
||||
}
|
||||
|
||||
|
||||
// If possible, redirect the coercion from String to NSString.
|
||||
if (TC.isBridgedDynamicConversion(protocol->getDeclaredType(), type)) {
|
||||
auto NSStringType = TC.getNSStringType(DC);
|
||||
|
||||
if (!NSStringType.isNull()) {
|
||||
simplifyRestrictedConstraint(ConversionRestrictionKind::User,
|
||||
type,
|
||||
NSStringType,
|
||||
TypeMatchKind::Conversion,
|
||||
TMF_GenerateConstraints,
|
||||
locator);
|
||||
|
||||
return SolutionKind::Solved;
|
||||
}
|
||||
}
|
||||
|
||||
// There's nothing more we can do; fail.
|
||||
recordFailure(getConstraintLocator(locator),
|
||||
Failure::DoesNotConformToProtocol, type,
|
||||
|
||||
Reference in New Issue
Block a user