mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
SILGen: just for fun let's do toll-free bridging for <T : NSError> archetypes too
Swift SVN r31262
This commit is contained in:
@@ -279,9 +279,12 @@ static bool isBridgedErrorClass(SILModule &M,
|
||||
if (!t)
|
||||
return false;
|
||||
|
||||
if (auto archetypeType = t->getAs<ArchetypeType>())
|
||||
t = archetypeType->getSuperclass();
|
||||
|
||||
// NSError (TODO: and CFError) can be bridged.
|
||||
auto errorType = M.Types.getNSErrorType();
|
||||
if (errorType && t->isEqual(errorType)) {
|
||||
if (t && errorType && t->isEqual(errorType)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,13 @@ func NSErrorErrorType_erasure(x: NSError) -> ErrorType {
|
||||
return x
|
||||
}
|
||||
|
||||
// CHECK-LABEL: sil hidden @_TF10objc_error34NSErrorErrorType_archetype_erasureuRdq_CSo7NSError_Fq_PSs9ErrorType_
|
||||
// CHECK: [[ERROR_TYPE:%.*]] = init_existential_ref %0 : $T : $T, $ErrorType
|
||||
// CHECK: return [[ERROR_TYPE]]
|
||||
func NSErrorErrorType_archetype_erasure<T : NSError>(t: T) -> ErrorType {
|
||||
return t
|
||||
}
|
||||
|
||||
// Test patterns that are non-trivial, but irrefutable. SILGen shouldn't crash
|
||||
// on these.
|
||||
func test_doesnt_throw() {
|
||||
|
||||
Reference in New Issue
Block a user