forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobjc_enum.swift
37 lines (28 loc) · 1.23 KB
/
objc_enum.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// RUN: %target-parse-verify-swift
@objc enum Foo: Int {
case Zim, Zang, Zung
}
@objc enum Generic<T>: Int { // expected-error{{'@objc' enum cannot be generic}} {{1-7=}}
case Zim, Zang, Zung
}
@objc(EnumRuntimeName) enum RuntimeNamed: Int { // expected-error{{'@objc' enum cannot have a name}}
case Zim, Zang, Zung
}
@objc enum NoRawType { // expected-error{{'@objc' enum must declare an integer raw type}}
case Zim, Zang, Zung
}
@objc enum NonIntegerRawType: Float { // expected-error{{'@objc' enum raw type 'Float' is not an integer type}}
// expected-error@-1{{type 'NonIntegerRawType' does not conform to protocol 'RawRepresentable'}}
case Zim = 1.0, Zang = 1.5, Zung = 2.0
}
enum NonObjCEnum: Int {
case Zim, Zang, Zung
}
class Bar {
@objc func foo(x: Foo) {}
@objc func nonObjC(x: NonObjCEnum) {} //expected-error{{type of the parameter cannot be represented in Objective-C}} //expected-note{{non-'@objc' enums cannot be represented in Objective-C}}
}
// <rdar://problem/23681566> @objc enums with payloads rejected with no source location info
@objc enum r23681566 : Int { // expected-note {{declared raw type 'Int' here}}
case Foo(progress: Int) // expected-error {{enum with raw type cannot have cases with arguments}}
}