Files
swift-mirror/test/Generics/inverse_generics_stdlib.swift
Kavon Farvardin ec4a125f3e NCGenerics: ext's might not infer invertible req's
If the extension adds conformance to an invertible protocol, it's
confusing for people to also infer conditional requirements on the
generic parameters for those invertible protocols. This came up in the
review of SE-427.
2024-06-12 14:44:22 -07:00

32 lines
777 B
Swift

// RUN: %target-typecheck-verify-swift -parse-stdlib -module-name Swift -enable-experimental-feature BuiltinModule -enable-experimental-feature NonescapableTypes
/// This test specifically covers constructs that are only valid in the stdlib.
import Builtin
@_marker public protocol Copyable: ~Escapable {}
@_marker public protocol Escapable: ~Copyable {}
struct NC: ~Copyable {}
@frozen public struct UnsafePointer<T: ~Copyable>: Copyable {
var value: Builtin.RawPointer
}
@frozen
public enum Optional<T: ~Copyable>: ~Copyable {
case some(T)
case none
}
extension Optional: Copyable where T: Copyable {}
public func wrapping<T: ~Copyable>(_ t: consuming T) -> T? {
return .some(t)
}
// No ownership required.
func checkCopyability(_ t: UnsafePointer<NC>) {}