Runtime: Let structural types be cast out of boxed AnyObjects too.

This commit is contained in:
Joe Groff
2016-07-28 12:24:54 -07:00
parent e7e8b660a6
commit d206bb5aa1
2 changed files with 38 additions and 15 deletions

View File

@@ -2281,6 +2281,14 @@ bool swift::swift_dynamicCast(OpaqueValue *dest,
if (!srcType)
return unwrapResult.success;
#if SWIFT_OBJC_INTEROP
// A class or AnyObject reference may point at a boxed SwiftValue.
if (tryDynamicCastBoxedSwiftValue(dest, src, srcType,
targetType, flags)) {
return true;
}
#endif
switch (targetType->getKind()) {
// Handle wrapping an Optional target.
case MetadataKind::Optional: {
@@ -2411,17 +2419,6 @@ bool swift::swift_dynamicCast(OpaqueValue *dest,
if (tryDynamicCastNSErrorToValue(dest, src, srcType, targetType, flags)) {
return true;
}
#endif
SWIFT_FALLTHROUGH;
}
case MetadataKind::Existential: {
#if SWIFT_OBJC_INTEROP
// A class or AnyObject reference may point at a boxed SwiftValue.
if (tryDynamicCastBoxedSwiftValue(dest, src, srcType,
targetType, flags)) {
return true;
}
#endif
break;
}
@@ -2436,6 +2433,7 @@ bool swift::swift_dynamicCast(OpaqueValue *dest,
}
break;
case MetadataKind::Existential:
case MetadataKind::ExistentialMetatype:
case MetadataKind::Enum:
case MetadataKind::Optional: