Files
swift-mirror/test/Sema/moveonly_objc_enum.swift
Kavon Farvardin a4e9919f29 [Sema] require value deinit absence for Copyable
A value type like a struct or enum cannot conform to Copyable if it has
a deinit. When NoncopyableGenerics is enabled, we make that part of what
 is required to verify that such a nominal type conforms to Copyable.

This change also does some refactoring to share common code to point out
 how to make a type noncopyable.
2023-11-06 19:44:58 -08:00

20 lines
720 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 {}
}
@_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
}