Skip to content

Commit 21a7fba

Browse files
committed
More tests for Bool raw values of enums
1 parent 9243c61 commit 21a7fba

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

test/decl/enum/bool_raw_value.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,13 @@ enum IsRecursive : Bool, Equatable, Hashable {
1414
case recursive=false
1515
case nonrecursive // expected-error{{enum case must declare a raw value when the preceding raw value is not an integer}}
1616
}
17+
18+
enum IsRecursiveBad1Integral : Bool, Equatable, Hashable {
19+
case recursive = 0
20+
case nonrecursive
21+
}
22+
23+
// expected-error @+1{{'IsRecursiveBad2' declares raw type 'Int', but does not conform to RawRepresentable and conformance could not be synthesized}}
24+
enum IsRecursiveBad2 : Int, Equatable, Hashable {
25+
case recursive = false // expected-error{{cannot convert value of type 'Bool' to raw type 'Int'}}
26+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %target-typecheck-verify-swift
2+
// REQUIRES: objc_interop
3+
4+
extension Bool: ExpressibleByIntegerLiteral {
5+
public init(integerLiteral value: Int) {
6+
self = value != 0
7+
}
8+
}
9+
10+
@objc enum IsDefinitelyRecursive : Bool, Equatable, Hashable { // expected-error{{'@objc' enum raw type 'Bool' is not an integer type}}
11+
case recursive=false
12+
}

0 commit comments

Comments
 (0)