File: objc_enum.swift

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (36 lines) | stat: -rw-r--r-- 1,287 bytes parent folder | download
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-typecheck-verify-swift -enable-objc-interop

@objc enum Foo: Int32 {
  case Zim, Zang, Zung
}

@objc enum Generic<T>: Int32 { // expected-error{{'@objc' enum cannot be generic}} {{1-7=}}
  case Zim, Zang, Zung
}

@objc(EnumRuntimeName) enum RuntimeNamed: Int32 {
  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}}
  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 : Int32 {  // expected-error {{'r23681566' declares raw type 'Int32', but does not conform to RawRepresentable and conformance could not be synthesized}} expected-note {{declared raw type 'Int32' here}}
  case Foo(progress: Int)     // expected-error {{enum with raw type cannot have cases with arguments}}
}