Skip to content

Commit 6d1e5c3

Browse files
committed
[test] coverage for conditional conformances
1 parent 25aa49b commit 6d1e5c3

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

test/Generics/inverse_generics.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,3 +424,16 @@ public struct Record<Output> {
424424
}
425425
protocol P {}
426426
extension Record : Decodable where Output : P {}
427+
428+
// Expect that if Copyable is an inherited protocol, then conditional
429+
// conformances carry that through, making the Blahaj conditionally Copyable.
430+
struct Blahaj<Value>: ~Copyable {
431+
deinit {} // expected-error {{deinitializer cannot be declared in generic struct 'Blahaj' that conforms to 'Copyable'}}
432+
}
433+
extension Blahaj: Q where Value: Q {}
434+
protocol Q: Copyable {}
435+
436+
// expected-note@+2 3{{add}}
437+
// expected-error@+1 {{parameter of noncopyable type 'Blahaj<T>' must specify ownership}}
438+
func testBlahaj<T, U: Q>(_ x: Blahaj<T>,
439+
_ y: Blahaj<U>) {}

0 commit comments

Comments
 (0)