Files
swift-mirror/test/Generics/inverse_protocols_errors.swift
Kavon Farvardin d5f2d54ca7 [Sema] initial overhaul of isNoncopyable
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.
2023-10-18 13:45:50 -07:00

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!
}