1- // RUN: %target-sil-opt -test-runner %s -o /dev/null 2>&1 | %FileCheck %s
1+ // RUN: %target-sil-opt -test-runner \
2+ // RUN: -enable-experimental-feature NoncopyableGenerics -enable-experimental-feature NonescapableTypes \
3+ // RUN: -enable-experimental-feature BitwiseCopyable \
4+ // RUN: %s -o /dev/null 2>&1 | %FileCheck %s
25
36sil_stage raw
47
@@ -7,6 +10,8 @@ import Swift
710
811struct S : ~Copyable {}
912
13+ struct SCopyable {}
14+
1015// CHECK-LABEL: begin {{.*}} print-type-lowering with: @argument[0]
1116// CHECK: isLexical: true
1217// CHECK-LABEL: end {{.*}} print-type-lowering with: @argument[0]
@@ -106,3 +111,203 @@ entry(%addr : $*Builtin.RawPointer):
106111 specify_test "print_ast_type_lowering %instance"
107112 return undef : $()
108113}
114+
115+ struct GSNC<T: ~Copyable>: ~Copyable {
116+ var x: T
117+ }
118+
119+ extension GSNC: Copyable where T: Copyable {}
120+
121+ struct GSNE<T: ~Escapable>: ~Escapable {
122+ var x: T
123+
124+ // 60_MERGE: an explicit initializer is temporarily required until initializer inferrence is merged.
125+ init(x: consuming T) { self.x = x }
126+ }
127+
128+ extension GSNE: Escapable where T: Escapable {}
129+
130+ enum GENC<T: ~Copyable>: ~Copyable {
131+ case x(T)
132+ case knoll
133+ }
134+
135+ enum GENE<T: ~Escapable>: ~Escapable {
136+ case x(T)
137+ case knoll
138+ }
139+
140+ extension GENC: Copyable where T: Copyable {}
141+
142+ extension GENE: Escapable where T: Escapable {}
143+
144+ // TODO: We should have 'isTrivial: true' for the following four tests: gsnc_argument, gsne_argument, genc_argument,
145+ // gene_argument. This requires fixing Typelowering visitAnyStructType and visitAnyEnumType to apply the current
146+ // abstraction pattern for each stored property that refers to an archetype. Similar how TypeLowering handles the
147+ // aggregate type by calling AbstractionPattern::conformsToKnownProtocol.
148+ //
149+ // CHECK-LABEL: begin running test 1 of 1 on gsnc_argument: print-type-lowering with: @argument[0]
150+ // CHECK: Type Lowering for lowered type: $*GSNC<T>.
151+ // CHECK: isTrivial: false.
152+ // CHECK-LABEL: end running test 1 of 1 on gsnc_argument: print-type-lowering with: @argument[0]
153+ sil [ossa] @gsnc_argument : $@convention(thin) <T: _BitwiseCopyable> (@in_guaranteed GSNC<T>) -> () {
154+ bb0(%0 : $*GSNC<T>):
155+ specify_test "print-type-lowering @argument[0]"
156+ %retval = tuple ()
157+ return %retval : $()
158+ }
159+
160+ // CHECK-LABEL: begin running test 1 of 1 on gsne_argument: print-type-lowering with: @argument[0]
161+ // CHECK: isTrivial: false.
162+ // CHECK-LABEL: end running test 1 of 1 on gsne_argument: print-type-lowering with: @argument[0]
163+ sil [ossa] @gsne_argument : $@convention(thin) <T: _BitwiseCopyable> (@in_guaranteed GSNE<T>) -> () {
164+ bb0(%0 : $*GSNE<T>):
165+ specify_test "print-type-lowering @argument[0]"
166+ %retval = tuple ()
167+ return %retval : $()
168+ }
169+
170+ // CHECK-LABEL: begin running test 1 of 1 on genc_argument: print-type-lowering with: @argument[0]
171+ // CHECK: isTrivial: false.
172+ // CHECK-LABEL: end running test 1 of 1 on genc_argument: print-type-lowering with: @argument[0]
173+ sil [ossa] @genc_argument : $@convention(thin) <T: _BitwiseCopyable> (@in_guaranteed GENC<T>) -> () {
174+ bb0(%0 : $*GENC<T>):
175+ specify_test "print-type-lowering @argument[0]"
176+ %retval = tuple ()
177+ return %retval : $()
178+ }
179+
180+ // CHECK-LABEL: begin running test 1 of 1 on gene_argument: print-type-lowering with: @argument[0]
181+ // CHECK: isTrivial: false.
182+ // CHECK-LABEL: end running test 1 of 1 on gene_argument: print-type-lowering with: @argument[0]
183+ sil [ossa] @gene_argument : $@convention(thin) <T: _BitwiseCopyable> (@in_guaranteed GENE<T>) -> () {
184+ bb0(%0 : $*GENE<T>):
185+ specify_test "print-type-lowering @argument[0]"
186+ %retval = tuple ()
187+ return %retval : $()
188+ }
189+
190+ struct Bitwise<T: _BitwiseCopyable>: _BitwiseCopyable {
191+ var x: T
192+ }
193+
194+ // TODO: This should return 'isTrivial: true'. This is particularly inexcusable because the 'Bitwise' cannot be
195+ // nontrivial over any 'T', *and* the declaration itself is declared BitwiseCopyable.
196+ //
197+ // CHECK-LABEL: begin running test 1 of 1 on bitwise_argument: print-type-lowering with: @argument[0]
198+ // CHECK: isTrivial: false.
199+ // CHECK-LABEL: end running test 1 of 1 on bitwise_argument: print-type-lowering with: @argument[0]
200+ sil [ossa] @bitwise_argument : $@convention(thin) <T: _BitwiseCopyable> (@in_guaranteed Bitwise<T>) -> () {
201+ bb0(%0 : $*Bitwise<T>):
202+ specify_test "print-type-lowering @argument[0]"
203+ %retval = tuple ()
204+ return %retval : $()
205+ }
206+
207+ // CHECK-LABEL: begin running test 1 of 1 on gsnc_specialized_argument: print-type-lowering with: @argument[0]
208+ // CHECK: isTrivial: true.
209+ // CHECK-LABEL: end running test 1 of 1 on gsnc_specialized_argument: print-type-lowering with: @argument[0]
210+ sil [ossa] @gsnc_specialized_argument : $@convention(thin) (@in_guaranteed GSNC<SCopyable>) -> () {
211+ bb0(%0 : $*GSNC<SCopyable>):
212+ specify_test "print-type-lowering @argument[0]"
213+ %retval = tuple ()
214+ return %retval : $()
215+ }
216+
217+ // CHECK-LABEL: begin running test 1 of 1 on gsne_specialized_argument: print-type-lowering with: @argument[0]
218+ // CHECK: isTrivial: true.
219+ // CHECK-LABEL: end running test 1 of 1 on gsne_specialized_argument: print-type-lowering with: @argument[0]
220+ sil [ossa] @gsne_specialized_argument : $@convention(thin) (@in_guaranteed GSNE<SCopyable>) -> () {
221+ bb0(%0 : $*GSNE<SCopyable>):
222+ specify_test "print-type-lowering @argument[0]"
223+ %retval = tuple ()
224+ return %retval : $()
225+ }
226+
227+ // CHECK-LABEL: begin running test 1 of 1 on genc_specialized_argument: print-type-lowering with: @argument[0]
228+ // CHECK: isTrivial: true.
229+ // CHECK-LABEL: end running test 1 of 1 on genc_specialized_argument: print-type-lowering with: @argument[0]
230+ sil [ossa] @genc_specialized_argument : $@convention(thin) (@in_guaranteed GENC<SCopyable>) -> () {
231+ bb0(%0 : $*GENC<SCopyable>):
232+ specify_test "print-type-lowering @argument[0]"
233+ %retval = tuple ()
234+ return %retval : $()
235+ }
236+
237+ // CHECK-LABEL: begin running test 1 of 1 on gene_specialized_argument: print-type-lowering with: @argument[0]
238+ // CHECK: isTrivial: true.
239+ // CHECK-LABEL: end running test 1 of 1 on gene_specialized_argument: print-type-lowering with: @argument[0]
240+ sil [ossa] @gene_specialized_argument : $@convention(thin) (@in_guaranteed GENE<SCopyable>) -> () {
241+ bb0(%0 : $*GENE<SCopyable>):
242+ specify_test "print-type-lowering @argument[0]"
243+ %retval = tuple ()
244+ return %retval : $()
245+ }
246+
247+ struct GSNCInt<T: ~Copyable>: ~Copyable {
248+ var x: Int
249+ }
250+
251+ extension GSNCInt: Copyable where T: Copyable {}
252+
253+ struct GSNEInt<T: ~Escapable>: ~Escapable {
254+ var x: Int
255+ @_unsafeNonescapableResult
256+ init() { x = 0 }
257+ }
258+
259+ extension GSNEInt: Escapable where T: Escapable {}
260+
261+ enum GENCInt<T: ~Copyable>: ~Copyable {
262+ case x(Int)
263+ case knoll
264+ }
265+
266+ enum GENEInt<T: ~Escapable>: ~Escapable {
267+ case x(Int)
268+ case knoll
269+ }
270+
271+ extension GENCInt: Copyable where T: Copyable {}
272+
273+ extension GENEInt: Escapable where T: Escapable {}
274+
275+ // CHECK-LABEL: begin running test 1 of 1 on gsncint_argument: print-type-lowering with: @argument[0]
276+ // CHECK: isTrivial: true.
277+ // CHECK-LABEL: end running test 1 of 1 on gsncint_argument: print-type-lowering with: @argument[0]
278+ sil [ossa] @gsncint_argument : $@convention(thin) <T: _BitwiseCopyable> (@in_guaranteed GSNCInt<T>) -> () {
279+ bb0(%0 : $*GSNCInt<T>):
280+ specify_test "print-type-lowering @argument[0]"
281+ %retval = tuple ()
282+ return %retval : $()
283+ }
284+
285+ // CHECK-LABEL: begin running test 1 of 1 on gsneint_argument: print-type-lowering with: @argument[0]
286+ // CHECK: isTrivial: true.
287+ // CHECK-LABEL: end running test 1 of 1 on gsneint_argument: print-type-lowering with: @argument[0]
288+ sil [ossa] @gsneint_argument : $@convention(thin) <T: _BitwiseCopyable> (@in_guaranteed GSNEInt<T>) -> () {
289+ bb0(%0 : $*GSNEInt<T>):
290+ specify_test "print-type-lowering @argument[0]"
291+ %retval = tuple ()
292+ return %retval : $()
293+ }
294+
295+ // CHECK-LABEL: begin running test 1 of 1 on gencint_argument: print-type-lowering with: @argument[0]
296+ // CHECK: isTrivial: true.
297+ // CHECK-LABEL: end running test 1 of 1 on gencint_argument: print-type-lowering with: @argument[0]
298+ sil [ossa] @gencint_argument : $@convention(thin) <T: _BitwiseCopyable> (@in_guaranteed GENCInt<T>) -> () {
299+ bb0(%0 : $*GENCInt<T>):
300+ specify_test "print-type-lowering @argument[0]"
301+ %retval = tuple ()
302+ return %retval : $()
303+ }
304+
305+ // CHECK-LABEL: begin running test 1 of 1 on geneint_argument: print-type-lowering with: @argument[0]
306+ // CHECK: isTrivial: true.
307+ // CHECK-LABEL: end running test 1 of 1 on geneint_argument: print-type-lowering with: @argument[0]
308+ sil [ossa] @geneint_argument : $@convention(thin) <T: _BitwiseCopyable> (@in_guaranteed GENEInt<T>) -> () {
309+ bb0(%0 : $*GENEInt<T>):
310+ specify_test "print-type-lowering @argument[0]"
311+ %retval = tuple ()
312+ return %retval : $()
313+ }
0 commit comments