Runtime: Implement dynamic cast bridging from NSError to bridged error enums.

This allows ErrorTypes referencing Cocoa NSErrors to be pattern-matched against our bridged enums, at least dynamically. (The compiler still doesn't understand these bridging conversions yet.)

Swift SVN r26839
This commit is contained in:
Joe Groff
2015-04-02 00:19:30 +00:00
parent 38cc1fe5c6
commit 72643fd774
5 changed files with 160 additions and 6 deletions

View File

@@ -131,6 +131,18 @@ extern "C" void swift_getErrorValue(const SwiftError *errorObject,
void **scratch,
ErrorValueResult *out);
#if SWIFT_OBJC_INTEROP
/// Attempt to dynamically cast an NSError instance to a Swift ErrorType
/// implementation using the _ObjectiveCBridgeableErrorType protocol.
///
/// srcType must be some kind of class metadata.
bool tryDynamicCastNSErrorToValue(OpaqueValue *dest,
OpaqueValue *src,
const Metadata *srcType,
const Metadata *destType,
DynamicCastFlags flags);
#endif
} // namespace swift
#endif