mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
We used to allow @objc enums on Linux, where Objective-C interop is disabled, because the check first looked for an import of the Foundation module (which could be the non-Objective-C corelibs-foundation) before checking if Objective-C interop was enabled. Since @objc enums don't actually depend on Foundation or Objective-C and only have a different layout in IRGen, let's bring back and formalize the old behavior. Fixes https://bugs.swift.org/browse/SR-14548 / rdar://problem/77325078.
31 lines
827 B
Swift
31 lines
827 B
Swift
// RUN: %target-swift-frontend -emit-ir %s | %FileCheck %s
|
|
|
|
// REQUIRES: CPU=x86_64
|
|
|
|
@objc public enum ExportedToObjC: Int32 {
|
|
case Foo = -1, Bar, Bas
|
|
}
|
|
|
|
// CHECK-LABEL: define{{( protected)?( dllexport)?}} swiftcc i32 @"$s9objc_enum0a1_B7_injectAA14ExportedToObjCOyF"()
|
|
// CHECK: ret i32 -1
|
|
public func objc_enum_inject() -> ExportedToObjC {
|
|
return .Foo
|
|
}
|
|
|
|
// CHECK-LABEL: define{{( protected)?( dllexport)?}} swiftcc i64 @"$s9objc_enum0a1_B7_switchySiAA14ExportedToObjCOF"(i32 %0)
|
|
// CHECK: switch i32 %0, label {{%.*}} [
|
|
// CHECK: i32 -1, label {{%.*}}
|
|
// CHECK: i32 0, label {{%.*}}
|
|
// CHECK: i32 1, label {{%.*}}
|
|
public func objc_enum_switch(_ x: ExportedToObjC) -> Int {
|
|
switch x {
|
|
case .Foo:
|
|
return 0
|
|
case .Bar:
|
|
return 1
|
|
case .Bas:
|
|
return 2
|
|
}
|
|
}
|
|
|