Don't classify bridging casts as WillSucceed if the object-to-value cast can fail.

When casting from an object type to a bridged Swift value type, classifyDynamicCast would use the cast classification for the target type's bridged object type, which would be trivially WillSucceed for thinks like NSNumber-to-Int or NSError-to-SomeError, even though the bridging itself could fail. Fixing this fixes SR-2920|rdar://problem/31404281.
This commit is contained in:
Joe Groff
2017-05-11 19:37:58 -07:00
parent e353163b58
commit 4e9851b032
9 changed files with 242 additions and 187 deletions

View File

@@ -3559,7 +3559,7 @@ ConstraintSystem::simplifyBridgingConstraint(Type type1,
// We accepted these coercions in Swift 3 mode, so we have to live with
// them (but give a warning) in that language mode.
if (!TC.Context.LangOpts.isSwiftVersion3()
&& TC.isObjCClassWithMultipleSwiftBridgedTypes(objcClass, DC))
&& TC.Context.isObjCClassWithMultipleSwiftBridgedTypes(objcClass))
return SolutionKind::Error;
// If the bridged value type is generic, the generic arguments