Files
swift-mirror/test/Sema/conditionally_copyable.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

23 lines
705 B
Swift

// RUN: %target-typecheck-verify-swift
struct G<T: ~Copyable>: ~Copyable {}
extension G: Copyable where T: Copyable {}
protocol Base {}
protocol Derived: Base {}
// Normally we would require the conditional conformance 'G: Base' to be
// explicitly declared, but that would break source compatibility if G
// used to be unconditionally Copyable.
extension G: Derived {} // expected-note {{requirement from conditional conformance of 'G<NotCopyable>' to 'Base'}}
struct NotCopyable: ~Copyable {}
struct IsCopyable {}
func f<T: Base>(_: T.Type) {}
f(G<NotCopyable>.self) // expected-error {{global function 'f' requires that 'NotCopyable' conform to 'Copyable'}}
f(G<IsCopyable>.self) // accepted