Files
swift-mirror/test/Sema/moveonly_objc_enum.swift
Kavon Farvardin 79332c19b0 emit error when a noncopyable enum has a raw type
previously I was allowing these because I thought there was
some representational difference if the enum is raw. it
turns out that a raw enum is only useful if you synthesize
conformance to RawRepresentable. since I disabled that
synthesis it's kind of silly to still allow the raw type
to be written at all.

rdar://110539937
2023-06-21 11:21:49 -07:00

20 lines
798 B
Swift

// RUN: %target-typecheck-verify-swift -enable-experimental-feature MoveOnlyEnumDeinits
// REQUIRES: objc_interop
// Validate that we can't mark an objc enum as move only.
@_moveOnly
@objc enum Foo : Int { // expected-error {{noncopyable enums cannot be marked '@objc'}}
// expected-error@-1 {{'Foo' declares raw type 'Int', but cannot yet conform to RawRepresentable because it is noncopyable}}
case X, Y, Z
deinit {} // expected-error {{deinitializers cannot be declared on an @objc enum type}}
}
@_moveOnly
@objc enum Foo2 : Int { // expected-error {{noncopyable enums cannot be marked '@objc'}}
// expected-error@-1 {{'Foo2' declares raw type 'Int', but cannot yet conform to RawRepresentable because it is noncopyable}}
case X, Y, Z
}