1
1
// RUN: %target-swift-frontend -typecheck -debug-generic-signatures %s 2>&1 | %FileCheck %s
2
2
3
- // XFAIL: noncopyable_generics
4
-
5
3
// CHECK-LABEL: main.(file).P1@
6
4
// CHECK: Requirement signature: <Self>
7
5
protocol P1 {
@@ -27,7 +25,7 @@ protocol P3 {
27
25
// CHECK-LABEL: StructDecl name=Basic
28
26
// CHECK: (normal_conformance type="Basic" protocol="P1"
29
27
// CHECK-NEXT: (assoc_type req="A" type="Int")
30
- // CHECK-NEXT: (value req="f()" witness="main.(file).Basic.f()@{{.*}}"))
28
+ // CHECK-NEXT: (value req="f()" witness="main.(file).Basic.f()@{{.*}}")
31
29
struct Basic : P1 {
32
30
typealias A = Int
33
31
func f( ) -> Int { fatalError ( ) }
@@ -36,9 +34,15 @@ struct Basic: P1 {
36
34
// Recursive conformances should have finite output.
37
35
38
36
// CHECK-LABEL: StructDecl name=Recur
37
+ // CHECK-NEXT: (builtin_conformance type="Recur" protocol="Copyable")
38
+ // CHECK-NEXT: (builtin_conformance type="Recur" protocol="Escapable")
39
39
// CHECK-NEXT: (normal_conformance type="Recur" protocol="P2"
40
40
// CHECK-NEXT: (assoc_type req="A" type="Recur")
41
41
// CHECK-NEXT: (assoc_type req="B" type="Recur")
42
+ // CHECK-NEXT: (assoc_conformance type="Self" proto="Copyable"
43
+ // CHECK-NEXT: (builtin_conformance type="Recur" protocol="Copyable"))
44
+ // CHECK-NEXT: (assoc_conformance type="Self" proto="Escapable"
45
+ // CHECK-NEXT: (builtin_conformance type="Recur" protocol="Escapable"))
42
46
// CHECK-NEXT: (assoc_conformance type="Self.A" proto="P2"
43
47
// CHECK-NEXT: (normal_conformance type="Recur" protocol="P2" <details printed above>))
44
48
// CHECK-NEXT: (assoc_conformance type="Self.B" proto="P2"
@@ -51,13 +55,23 @@ struct Recur: P2 {
51
55
// The full information about a conformance doesn't need to be printed twice.
52
56
53
57
// CHECK-LABEL: StructDecl name=NonRecur
58
+ // CHECK-NEXT: (builtin_conformance type="NonRecur" protocol="Copyable")
59
+ // CHECK-NEXT: (builtin_conformance type="NonRecur" protocol="Escapable")
54
60
// CHECK-NEXT: (normal_conformance type="NonRecur" protocol="P2"
55
61
// CHECK-NEXT: (assoc_type req="A" type="Recur")
56
62
// CHECK-NEXT: (assoc_type req="B" type="Recur")
63
+ // CHECK-NEXT: (assoc_conformance type="Self" proto="Copyable"
64
+ // CHECK-NEXT: (builtin_conformance type="NonRecur" protocol="Copyable"))
65
+ // CHECK-NEXT: (assoc_conformance type="Self" proto="Escapable"
66
+ // CHECK-NEXT: (builtin_conformance type="NonRecur" protocol="Escapable"))
57
67
// CHECK-NEXT: (assoc_conformance type="Self.A" proto="P2"
58
68
// CHECK-NEXT: (normal_conformance type="Recur" protocol="P2"
59
69
// CHECK-NEXT: (assoc_type req="A" type="Recur")
60
70
// CHECK-NEXT: (assoc_type req="B" type="Recur")
71
+ // CHECK-NEXT: (assoc_conformance type="Self" proto="Copyable"
72
+ // CHECK-NEXT: (builtin_conformance type="Recur" protocol="Copyable"))
73
+ // CHECK-NEXT: (assoc_conformance type="Self" proto="Escapable"
74
+ // CHECK-NEXT: (builtin_conformance type="Recur" protocol="Escapable"))
61
75
// CHECK-NEXT: (assoc_conformance type="Self.A" proto="P2"
62
76
// CHECK-NEXT: (normal_conformance type="Recur" protocol="P2" <details printed above>))
63
77
// CHECK-NEXT: (assoc_conformance type="Self.B" proto="P2"
@@ -79,7 +93,15 @@ struct Generic<T> {}
79
93
// CHECK-NEXT: (normal_conformance type="Generic<T>" protocol="P1"
80
94
// CHECK-NEXT: (assoc_type req="A" type="T")
81
95
// CHECK-NEXT: (value req="f()" witness="main.(file).Generic extension.f()@{{.*}}")
82
- // CHECK-NEXT: (requirement "T" conforms_to "P1")
96
+ // CHECK-NEXT: (assoc_conformance type="Self" proto="Copyable"
97
+ // CHECK-NEXT: (builtin_conformance type="Generic<T>" protocol="Copyable"))
98
+ // CHECK-NEXT: (assoc_conformance type="Self" proto="Escapable"
99
+ // CHECK-NEXT: (builtin_conformance type="Generic<T>" protocol="Escapable"))
100
+ // CHECK-NEXT: (assoc_conformance type="Self.A" proto="Copyable"
101
+ // CHECK-NEXT: (abstract_conformance protocol="Copyable"))
102
+ // CHECK-NEXT: (assoc_conformance type="Self.A" proto="Escapable"
103
+ // CHECK-NEXT: (abstract_conformance protocol="Escapable"))
104
+ // CHECK-NEXT: (requirement "T" conforms_to "P1"))
83
105
extension Generic : P1 where T: P1 {
84
106
typealias A = T
85
107
func f( ) -> T { fatalError ( ) }
@@ -96,6 +118,10 @@ class Super<T, U> {}
96
118
// CHECK-NEXT: (normal_conformance type="Super<T, U>" protocol="P2"
97
119
// CHECK-NEXT: (assoc_type req="A" type="T")
98
120
// CHECK-NEXT: (assoc_type req="B" type="T")
121
+ // CHECK-NEXT: (assoc_conformance type="Self" proto="Copyable"
122
+ // CHECK-NEXT: (builtin_conformance type="Super<T, U>" protocol="Copyable"))
123
+ // CHECK-NEXT: (assoc_conformance type="Self" proto="Escapable"
124
+ // CHECK-NEXT: (builtin_conformance type="Super<T, U>" protocol="Escapable"))
99
125
// CHECK-NEXT: (assoc_conformance type="Self.A" proto="P2"
100
126
// CHECK-NEXT: (abstract_conformance protocol="P2"))
101
127
// CHECK-NEXT: (assoc_conformance type="Self.B" proto="P2"
@@ -109,33 +135,47 @@ extension Super: P2 where T: P2, U: P2 {
109
135
110
136
// Inherited/specialized conformances.
111
137
// CHECK-LABEL: ClassDecl name=Sub
138
+ // CHECK-NEXT: (builtin_conformance type="Sub" protocol="Copyable")
139
+ // CHECK-NEXT: (builtin_conformance type="Sub" protocol="Escapable")
112
140
// CHECK-NEXT: (inherited_conformance type="Sub" protocol="P2"
113
141
// CHECK-NEXT: (specialized_conformance type="Super<NonRecur, Recur>" protocol="P2"
114
- // CHECK-NEXT: (substitution_map generic_signature=<T, U where T : P2, U : P2>
115
- // CHECK-NEXT: (substitution T ->
116
- // CHECK-NEXT: (struct_type decl="{{.*}}"))
117
- // CHECK-NEXT: (substitution U ->
118
- // CHECK-NEXT: (struct_type decl="{{.*}}"))
119
- // CHECK-NEXT: (conformance type="T"
120
- // CHECK-NEXT: (normal_conformance type="NonRecur" protocol="P2"
121
- // CHECK-NEXT: (assoc_type req="A" type="Recur")
122
- // CHECK-NEXT: (assoc_type req="B" type="Recur")
123
- // CHECK-NEXT: (assoc_conformance type="Self.A" proto="P2"
124
- // CHECK-NEXT: (normal_conformance type="Recur" protocol="P2"
125
- // CHECK-NEXT: (assoc_type req="A" type="Recur")
126
- // CHECK-NEXT: (assoc_type req="B" type="Recur")
127
- // CHECK-NEXT: (assoc_conformance type="Self.A" proto="P2"
128
- // CHECK-NEXT: (normal_conformance type="Recur" protocol="P2" <details printed above>))
129
- // CHECK-NEXT: (assoc_conformance type="Self.B" proto="P2"
130
- // CHECK-NEXT: (normal_conformance type="Recur" protocol="P2" <details printed above>))))
131
- // CHECK-NEXT: (assoc_conformance type="Self.B" proto="P2"
132
- // CHECK-NEXT: (normal_conformance type="Recur" protocol="P2" <details printed above>))))
133
- // CHECK-NEXT: (conformance type="U"
134
- // CHECK-NEXT: (normal_conformance type="Recur" protocol="P2" <details printed above>)))
142
+ // CHECK-NEXT: (substitution_map generic_signature=<T, U where T : P2, U : P2>
143
+ // CHECK-NEXT: (substitution T ->
144
+ // CHECK-NEXT: (struct_type decl="main.(file).NonRecur@{{.*}}"))
145
+ // CHECK-NEXT: (substitution U ->
146
+ // CHECK-NEXT: (struct_type decl="main.(file).Recur@{{.*}}"))
147
+ // CHECK-NEXT: (conformance type="T"
148
+ // CHECK-NEXT: (normal_conformance type="NonRecur" protocol="P2"
149
+ // CHECK-NEXT: (assoc_type req="A" type="Recur")
150
+ // CHECK-NEXT: (assoc_type req="B" type="Recur")
151
+ // CHECK-NEXT: (assoc_conformance type="Self" proto="Copyable"
152
+ // CHECK-NEXT: (builtin_conformance type="NonRecur" protocol="Copyable"))
153
+ // CHECK-NEXT: (assoc_conformance type="Self" proto="Escapable"
154
+ // CHECK-NEXT: (builtin_conformance type="NonRecur" protocol="Escapable"))
155
+ // CHECK-NEXT: (assoc_conformance type="Self.A" proto="P2"
156
+ // CHECK-NEXT: (normal_conformance type="Recur" protocol="P2"
157
+ // CHECK-NEXT: (assoc_type req="A" type="Recur")
158
+ // CHECK-NEXT: (assoc_type req="B" type="Recur")
159
+ // CHECK-NEXT: (assoc_conformance type="Self" proto="Copyable"
160
+ // CHECK-NEXT: (builtin_conformance type="Recur" protocol="Copyable"))
161
+ // CHECK-NEXT: (assoc_conformance type="Self" proto="Escapable"
162
+ // CHECK-NEXT: (builtin_conformance type="Recur" protocol="Escapable"))
163
+ // CHECK-NEXT: (assoc_conformance type="Self.A" proto="P2"
164
+ // CHECK-NEXT: (normal_conformance type="Recur" protocol="P2" <details printed above>))
165
+ // CHECK-NEXT: (assoc_conformance type="Self.B" proto="P2"
166
+ // CHECK-NEXT: (normal_conformance type="Recur" protocol="P2" <details printed above>))))
167
+ // CHECK-NEXT: (assoc_conformance type="Self.B" proto="P2"
168
+ // CHECK-NEXT: (normal_conformance type="Recur" protocol="P2" <details printed above>))))
169
+ // CHECK-NEXT: (conformance type="U"
170
+ // CHECK-NEXT: (normal_conformance type="Recur" protocol="P2" <details printed above>)))
135
171
// CHECK-NEXT: (<conditional requirements unable to be computed>)
136
172
// CHECK-NEXT: (normal_conformance type="Super<T, U>" protocol="P2"
137
173
// CHECK-NEXT: (assoc_type req="A" type="T")
138
174
// CHECK-NEXT: (assoc_type req="B" type="T")
175
+ // CHECK-NEXT: (assoc_conformance type="Self" proto="Copyable"
176
+ // CHECK-NEXT: (builtin_conformance type="Super<T, U>" protocol="Copyable"))
177
+ // CHECK-NEXT: (assoc_conformance type="Self" proto="Escapable"
178
+ // CHECK-NEXT: (builtin_conformance type="Super<T, U>" protocol="Escapable"))
139
179
// CHECK-NEXT: (assoc_conformance type="Self.A" proto="P2"
140
180
// CHECK-NEXT: (abstract_conformance protocol="P2"))
141
181
// CHECK-NEXT: (assoc_conformance type="Self.B" proto="P2"
@@ -148,26 +188,42 @@ class Sub: Super<NonRecur, Recur> {}
148
188
// should work through SubstitutionMaps.
149
189
150
190
// CHECK-LABEL: StructDecl name=RecurGeneric
191
+ // CHECK-NEXT: (builtin_conformance type="RecurGeneric<T>" protocol="Copyable")
192
+ // CHECK-NEXT: (builtin_conformance type="RecurGeneric<T>" protocol="Escapable")
151
193
// CHECK-NEXT: (normal_conformance type="RecurGeneric<T>" protocol="P3"
152
194
// CHECK-NEXT: (assoc_type req="A" type="RecurGeneric<T>")
195
+ // CHECK-NEXT: (assoc_conformance type="Self" proto="Copyable"
196
+ // CHECK-NEXT: (builtin_conformance type="RecurGeneric<T>" protocol="Copyable"))
197
+ // CHECK-NEXT: (assoc_conformance type="Self" proto="Escapable"
198
+ // CHECK-NEXT: (builtin_conformance type="RecurGeneric<T>" protocol="Escapable"))
153
199
// CHECK-NEXT: (assoc_conformance type="Self.A" proto="P3"
154
200
// CHECK-NEXT: (normal_conformance type="RecurGeneric<T>" protocol="P3" <details printed above>)))
155
201
struct RecurGeneric < T: P3 > : P3 {
156
202
typealias A = RecurGeneric < T >
157
203
}
158
204
159
205
// CHECK-LABEL: StructDecl name=Specialize
206
+ // CHECK-NEXT: (builtin_conformance type="Specialize" protocol="Copyable")
207
+ // CHECK-NEXT: (builtin_conformance type="Specialize" protocol="Escapable")
160
208
// CHECK-NEXT: (normal_conformance type="Specialize" protocol="P3"
161
209
// CHECK-NEXT: (assoc_type req="A" type="RecurGeneric<Specialize>")
210
+ // CHECK-NEXT: (assoc_conformance type="Self" proto="Copyable"
211
+ // CHECK-NEXT: (builtin_conformance type="Specialize" protocol="Copyable"))
212
+ // CHECK-NEXT: (assoc_conformance type="Self" proto="Escapable"
213
+ // CHECK-NEXT: (builtin_conformance type="Specialize" protocol="Escapable"))
162
214
// CHECK-NEXT: (assoc_conformance type="Self.A" proto="P3"
163
215
// CHECK-NEXT: (specialized_conformance type="Specialize.A" protocol="P3"
164
216
// CHECK-NEXT: (substitution_map generic_signature=<T where T : P3>
165
217
// CHECK-NEXT: (substitution T ->
166
- // CHECK-NEXT: (struct_type decl="{{.*}}"))
218
+ // CHECK-NEXT: (struct_type decl="main.(file).Specialize@ {{.*}}"))
167
219
// CHECK-NEXT: (conformance type="T"
168
220
// CHECK-NEXT: (normal_conformance type="Specialize" protocol="P3" <details printed above>)))
169
221
// CHECK-NEXT: (normal_conformance type="RecurGeneric<T>" protocol="P3"
170
222
// CHECK-NEXT: (assoc_type req="A" type="RecurGeneric<T>")
223
+ // CHECK-NEXT: (assoc_conformance type="Self" proto="Copyable"
224
+ // CHECK-NEXT: (builtin_conformance type="RecurGeneric<T>" protocol="Copyable"))
225
+ // CHECK-NEXT: (assoc_conformance type="Self" proto="Escapable"
226
+ // CHECK-NEXT: (builtin_conformance type="RecurGeneric<T>" protocol="Escapable"))
171
227
// CHECK-NEXT: (assoc_conformance type="Self.A" proto="P3"
172
228
// CHECK-NEXT: (normal_conformance type="RecurGeneric<T>" protocol="P3" <details printed above>))))))
173
229
struct Specialize : P3 {
0 commit comments