Files
swift-mirror/test/Sema/moveonly_experimental.swift
2024-07-23 11:05:33 -07:00

45 lines
1.4 KiB
Swift

// RUN: %target-typecheck-verify-swift
// this test verifies what features are still behind the experimental flag by not providing it.
struct SomeValue {}
class NoncopyableClass: ~Copyable {} // expected-error {{classes cannot be '~Copyable'}}
func checkOldConsumeName() {
let x = SomeValue()
let _ = _move x // expected-error {{cannot find '_move' in scope}}
// expected-error@-1 {{consecutive statements on a line must be separated by ';'}}
// expected-warning@-2 {{expression of type 'SomeValue' is unused}}
}
func checkBorrow() {
let x = SomeValue()
let _ = _borrow x // expected-error {{cannot find '_borrow' in scope}}
// expected-error@-1 {{consecutive statements on a line must be separated by ';'}}
// expected-warning@-2 {{expression of type 'SomeValue' is unused}}
}
func checkNoImplicitCopy1(@_noImplicitCopy x: SomeValue) {}
// expected-error@-1 {{Can not use feature when experimental move only is disabled! Pass the frontend flag -enable-experimental-move-only to swift to enable the usage of this language feature}}
func checkNoImplicitCopy2(_ x: SomeValue) {
@_noImplicitCopy let y = x
// expected-error@-1 {{Can not use feature when experimental move only is disabled! Pass the frontend flag -enable-experimental-move-only to swift to enable the usage of this language feature}}
checkNoImplicitCopy2(y)
}
// coverage to ensure the feature flag is working
#if $MoveOnly
func guardedFn() {}
#endif
func caller() {
guardedFn()
}