mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user