mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
This implementation has the function execute a request to scan the inheritance clause of non-protocol nominals for a `~Copyable`. For protocols, we look in the requirement signature. This isn't our final state, as the GenericEnvironment needs to be queried in general to determine of a Type is noncopyable. So for now checking for a `~Copyable` only makes sense for Decls.
28 lines
843 B
Swift
28 lines
843 B
Swift
// RUN: %target-typecheck-verify-swift -enable-experimental-feature NoncopyableGenerics
|
|
|
|
// REQUIRES: asserts
|
|
|
|
protocol RegularProto {}
|
|
protocol NCProto: ~Copyable, RegularProto {} // FIXME: ought to diagnose
|
|
|
|
protocol Hello: ~Copyable {
|
|
func greet(_ s: Self) // FIXME: should complain about no ownership!
|
|
}
|
|
|
|
struct RegularStruct: Hello {
|
|
func greet(_ s: Self) {}
|
|
}
|
|
|
|
struct NCThinger<T: ~Copyable>: ~Copyable, Hello {
|
|
let fd: Int = 0
|
|
deinit {}
|
|
|
|
func greet(_ f: Self) {}
|
|
// expected-error@-1 {{noncopyable parameter must specify its ownership}}
|
|
// expected-note@-2 {{add 'borrowing' for an immutable reference}}
|
|
// expected-note@-3 {{add 'inout' for a mutable reference}}
|
|
// expected-note@-4 {{add 'consuming' to take the value from the caller}}
|
|
|
|
func setThinger(_ t: T) {} // FIXME: should complain about no ownership!
|
|
}
|