mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[WIP] Emit nominal type access functions for imported types.
Emit nominal type access functions for imported types. These access functions work with non-unique metadata references, so they perform uniquing through the runtime on first access. Fixes rdar://problem/36430234.
This commit is contained in:
@@ -4,12 +4,14 @@
|
||||
|
||||
import StdlibUnittest
|
||||
import Foundation
|
||||
import CoreFoundation
|
||||
|
||||
let DemangleToMetadataTests = TestSuite("DemangleToMetadataObjC")
|
||||
|
||||
@objc class C : NSObject { }
|
||||
@objc enum E: Int { case a }
|
||||
@objc protocol P1 { }
|
||||
protocol P2 { }
|
||||
|
||||
DemangleToMetadataTests.test("@objc classes") {
|
||||
expectEqual(type(of: C()), _typeByMangledName("4main1CC")!)
|
||||
@@ -40,5 +42,31 @@ DemangleToMetadataTests.test("Classes that don't exist") {
|
||||
expectNil(_typeByMangledName("4main4BoomC"))
|
||||
}
|
||||
|
||||
// FIXME: Shouldn't need this?
|
||||
extension CFArray: P2 { }
|
||||
|
||||
DemangleToMetadataTests.test("CoreFoundation classes") {
|
||||
expectEqual(CFArray.self, _typeByMangledName("So10CFArrayRefa")!)
|
||||
}
|
||||
|
||||
DemangleToMetadataTests.test("Imported error types") {
|
||||
expectEqual(URLError.self, _typeByMangledName("10Foundation8URLErrorV")!)
|
||||
expectEqual(URLError.Code.self,
|
||||
_typeByMangledName("10Foundation8URLErrorV4CodeV")!)
|
||||
}
|
||||
|
||||
DemangleToMetadataTests.test("Imported swift_wrapper types") {
|
||||
expectEqual(URLFileResourceType.self,
|
||||
_typeByMangledName("So21NSURLFileResourceTypea")!)
|
||||
}
|
||||
|
||||
extension URLSessionTask.State: P2 { }
|
||||
|
||||
DemangleToMetadataTests.test("Imported enum types") {
|
||||
// FIXME: Should work
|
||||
// expectEqual(NSURLSessionTask.State.self,
|
||||
// _typeByMangledName("So21NSURLSessionTaskStateV")!)
|
||||
}
|
||||
|
||||
runAllTests()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user