mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
* [cxx-interop] Add Hashable conformance to imported enums Previously, imported enums only conformed to RawRepresentable and Equatable, so they could not be used as members of a Set or keys of a Dictionary. This patch adds Hashable conformance to give them that ability, as well as some test cases to clarify the expected behavior. Existing test cases are updated to reflect this new conformance. rdar://129713687
41 lines
1.5 KiB
Swift
41 lines
1.5 KiB
Swift
// RUN: %target-swift-ide-test -print-module -module-to-print=BoolEnums -I %S/Inputs -source-filename=x -enable-experimental-cxx-interop | %FileCheck %s
|
|
|
|
// TODO: these should be enums eventually (especially the enum class).
|
|
|
|
// CHECK: struct Maybe : Hashable, Equatable, RawRepresentable {
|
|
// CHECK-NEXT: init(_ rawValue: Bool)
|
|
// CHECK-NEXT: init(rawValue: Bool)
|
|
// CHECK-NEXT: var rawValue: Bool
|
|
// CHECK-NEXT: typealias RawValue = Bool
|
|
// CHECK-NEXT: }
|
|
// CHECK: var No: Maybe { get }
|
|
// CHECK: var Yes: Maybe { get }
|
|
|
|
// CHECK: struct BinaryNumbers : Hashable, Equatable, RawRepresentable {
|
|
// CHECK-NEXT: init(_ rawValue: Bool)
|
|
// CHECK-NEXT: init(rawValue: Bool)
|
|
// CHECK-NEXT: var rawValue: Bool
|
|
// CHECK-NEXT: typealias RawValue = Bool
|
|
// CHECK-NEXT: }
|
|
// CHECK: var One: BinaryNumbers { get }
|
|
// CHECK: var Zero: BinaryNumbers { get }
|
|
|
|
// CHECK: enum EnumClass : Bool {
|
|
// CHECK: init?(rawValue: Bool)
|
|
// CHECK: var rawValue: Bool { get }
|
|
// CHECK: typealias RawValue = Bool
|
|
// CHECK: case Foo
|
|
// CHECK: case Bar
|
|
// CHECK: }
|
|
|
|
// CHECK: struct WrapperStruct {
|
|
// CHECK-NEXT: init()
|
|
// TODO: where is "A" and "B"? They should be member variables.
|
|
// CHECK-NEXT: struct InnerBoolEnum : Hashable, Equatable, RawRepresentable {
|
|
// CHECK-NEXT: init(_ rawValue: Bool)
|
|
// CHECK-NEXT: init(rawValue: Bool)
|
|
// CHECK-NEXT: var rawValue: Bool
|
|
// CHECK-NEXT: typealias RawValue = Bool
|
|
// CHECK-NEXT: }
|
|
// CHECK-NEXT: }
|