mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +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.
22 lines
446 B
Swift
22 lines
446 B
Swift
// RUN: %target-typecheck-verify-swift -enable-experimental-feature NoncopyableGenerics
|
|
|
|
// REQUIRES: asserts
|
|
|
|
protocol Eq: ~Copyable {
|
|
func same(_ other: Self) -> Bool
|
|
}
|
|
|
|
struct File: ~Copyable, Eq {
|
|
let fd: Int = 0
|
|
deinit {}
|
|
|
|
func same(_ other: borrowing Self) -> Bool {
|
|
return fd == other.fd
|
|
}
|
|
}
|
|
|
|
// FIXME: missing ownership is not diagnosed!
|
|
func check<T: ~Copyable>(_ a: T, _ b: T) -> Bool where T: Eq {
|
|
return a.same(b)
|
|
}
|