mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
When we scan the type metadata records or conformances to look for a type by name, skip over indirect Objective-C class references. We won’t find anything new there, but we’ll currently crash if they exist.
45 lines
1.1 KiB
Swift
45 lines
1.1 KiB
Swift
// RUN: %target-run-simple-swift
|
|
// REQUIRES: executable_test
|
|
// REQUIRES: objc_interop
|
|
|
|
import StdlibUnittest
|
|
import Foundation
|
|
|
|
let DemangleToMetadataTests = TestSuite("DemangleToMetadataObjC")
|
|
|
|
@objc class C : NSObject { }
|
|
@objc enum E: Int { case a }
|
|
@objc protocol P1 { }
|
|
|
|
DemangleToMetadataTests.test("@objc classes") {
|
|
expectEqual(type(of: C()), _typeByMangledName("4main1CC")!)
|
|
}
|
|
|
|
DemangleToMetadataTests.test("@objc enums") {
|
|
expectEqual(type(of: E.a), _typeByMangledName("4main1EO")!)
|
|
}
|
|
|
|
func f1_composition_objc_protocol(_: P1) { }
|
|
|
|
DemangleToMetadataTests.test("@objc protocols") {
|
|
expectEqual(type(of: f1_composition_objc_protocol),
|
|
_typeByMangledName("yy4main2P1_pc")!)
|
|
}
|
|
|
|
DemangleToMetadataTests.test("Objective-C classes") {
|
|
expectEqual(type(of: NSObject()), _typeByMangledName("So8NSObjectC")!)
|
|
}
|
|
|
|
func f1_composition_NSCoding(_: NSCoding) { }
|
|
|
|
DemangleToMetadataTests.test("Objective-C protocols") {
|
|
expectEqual(type(of: f1_composition_NSCoding), _typeByMangledName("yySo8NSCoding_pc")!)
|
|
}
|
|
|
|
DemangleToMetadataTests.test("Classes that don't exist") {
|
|
expectNil(_typeByMangledName("4main4BoomC"))
|
|
}
|
|
|
|
runAllTests()
|
|
|