Files
swift-mirror/test/Generics/inverse_protocols.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

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