Skip to content

Commit 8650984

Browse files
committed
[NoncopyableGenerics] additional test coverage
1 parent 6e2f24d commit 8650984

File tree

1 file changed

+69
-3
lines changed

1 file changed

+69
-3
lines changed

test/Generics/inverse_signatures.swift

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,42 @@ func genericFn<T>(_ t: T) {}
1010
// CHECK: Generic signature: <T>
1111
func withInverse<T: ~Copyable>(_ t: borrowing T) {}
1212

13+
// CHECK-LABEL: .where1@
14+
// CHECK: Generic signature: <T>
15+
func where1<T>(_ t: borrowing T) where T: ~Copyable {}
16+
17+
// CHECK-LABEL: .where2@
18+
// CHECK: Generic signature: <T where T : NoCopyP>
19+
func where2<T>(_ t: borrowing T) where T: NoCopyP, T: ~Copyable {}
20+
21+
// CHECK-LABEL: .where3@
22+
// CHECK: Generic signature: <T where T : CopyP>
23+
func where3<T>(_ t: T) where T: CopyP, T: ~Copyable {}
24+
25+
// CHECK-LABEL: .where4@
26+
// CHECK: Generic signature: <T where T : Equatable>
27+
func where4<T>(_ t: borrowing T) where T: Equatable, T: ~Copyable {}
28+
29+
// CHECK-LABEL: .compose1@
30+
// CHECK: Generic signature: <T where T : NoCopyP>
31+
func compose1<T: NoCopyP & ~Copyable>(_ t: borrowing T) {}
32+
33+
// CHECK-LABEL: .compose2@
34+
// CHECK: Generic signature: <T where T : CopyP>
35+
func compose2<T: CopyP & ~Copyable>(_ t: T) {}
36+
37+
// CHECK-LABEL: .compose3@
38+
// CHECK: Canonical generic signature: <τ_0_0 where τ_0_0 : CopyP>
39+
func compose3(_ t: some CopyP & ~Copyable) {}
40+
41+
// CHECK-LABEL: .compose4@
42+
// CHECK: Canonical generic signature: <τ_0_0 where τ_0_0 : NoCopyP>
43+
func compose4(_ t: inout some NoCopyP & ~Copyable) {}
44+
45+
// CHECK-LABEL: .f1@
46+
// CHECK: Generic signature: <T where T : Copyable, T : NoCopyP>
47+
func f1<T: NoCopyP>(_ t: T) {}
48+
1349
// CHECK-LABEL: .withSome@
1450
// CHECK: Canonical generic signature: <τ_0_0 where τ_0_0 : Copyable>
1551
func withSome(_ t: some Any) {}
@@ -44,7 +80,7 @@ class C1_IC<T: ~Copyable, U> {}
4480

4581
// CHECK-LABEL: .C1_CI@
4682
// CHECK: Generic signature: <T, U where T : Copyable>
47-
class C1_CI<T, U: ~Copyable> {}
83+
class C1_CI<T, U> where U: ~Copyable {}
4884

4985
// CHECK-LABEL: .C1_II@
5086
// CHECK: Generic signature: <T, U>
@@ -54,9 +90,25 @@ class C1_II<T: ~Copyable, U: ~Copyable> {}
5490
// CHECK: Requirement signature: <Self>
5591
protocol NoCopyP: ~Copyable {}
5692

57-
// CHECK-LABEL: .P1@
93+
// CHECK-LABEL: .NoCopyP2@
94+
// CHECK: Requirement signature: <Self where Self : NoCopyP>
95+
protocol NoCopyP2 where Self: ~Copyable & NoCopyP {}
96+
97+
// CHECK-LABEL: .CopyP@
5898
// CHECK: Requirement signature: <Self where Self : Copyable>
59-
protocol P1 {}
99+
protocol CopyP {}
100+
101+
// CHECK-LABEL: .CopyP2@
102+
// CHECK: Requirement signature: <Self where Self : CopyP>
103+
protocol CopyP2: CopyP, ~Copyable {} // expected-warning {{protocol 'CopyP2' should be declared to refine 'Copyable' due to a same-type constraint on 'Self'}}
104+
105+
// CHECK-LABEL: .CopyP2_Fixed@
106+
// CHECK: Requirement signature: <Self where Self : CopyP>
107+
protocol CopyP2_Fixed: CopyP {}
108+
109+
// CHECK-LABEL: .CopyInheritsNC@
110+
// CHECK: Requirement signature: <Self where Self : Copyable, Self : NoCopyP>
111+
protocol CopyInheritsNC: NoCopyP {}
60112

61113
// CHECK-LABEL: .P2@
62114
// CHECK: <Self where Self : Copyable, Self.[P2]A : Copyable>
@@ -73,3 +125,17 @@ protocol P2_CI { associatedtype A: ~Copyable }
73125
// CHECK-LABEL: .P2_II@
74126
// CHECK: Requirement signature: <Self>
75127
protocol P2_II: ~Copyable { associatedtype A: ~Copyable }
128+
129+
// CHECK-LABEL: .Cond@
130+
// CHECK: Generic signature: <T>
131+
// CHECK-NEXT: Canonical generic signature: <τ_0_0>
132+
struct Cond<T: ~Copyable>: ~Copyable {}
133+
134+
// CHECK-LABEL: ExtensionDecl line={{.*}} base=Cond
135+
// CHECK: Generic signature: <T where T : Copyable>
136+
// CHECK-NEXT: Canonical generic signature: <τ_0_0 where τ_0_0 : Copyable>
137+
138+
// CHECK-LABEL: ExtensionDecl line={{.*}} base=Cond
139+
// CHECK: (normal_conformance type="Cond<T>" protocol="Copyable"
140+
// CHECK-NEXT: (requirement "T" conforms_to "Copyable"))
141+
extension Cond: Copyable where T: Copyable {}

0 commit comments

Comments
 (0)