@@ -243,6 +243,46 @@ func triggerUseLazy() {
243
243
_ = UseLazy < Int > ( wibble: [ 1 , 2 , 3 ] )
244
244
}
245
245
246
+ func computeInt( ) -> Int {
247
+ return 42
248
+ }
249
+
250
+ func triggerUseLazyTestAutoclosure( ) {
251
+ _ = UseLazy ( bar: computeInt ( ) )
252
+
253
+ // triggerUseLazyTestAutoclosure()
254
+ // CHECK-LABEL: sil hidden [ossa] @$s17property_wrappers29triggerUseLazyTestAutoclosureyyF
255
+
256
+ // computeInt() must not get called here
257
+ // CHECK-NOT: // function_ref computeInt()
258
+ // CHECK-NOT: function_ref @$s17property_wrappers10computeIntSiyF : $@convention(thin) () -> Int
259
+
260
+ // Rather, an implicit closure is referenced
261
+ // CHECK: // function_ref implicit closure #1 in triggerUseLazyTestAutoclosure()
262
+ // CHECK: function_ref @$s17property_wrappers29triggerUseLazyTestAutoclosureyyFSiycfu_ : $@convention(thin) () -> Int
263
+
264
+ // And the implicit closure calls computeInt()
265
+ // CHECK: sil private [transparent] [ossa] @$s17property_wrappers29triggerUseLazyTestAutoclosureyyFSiycfu_ : $@convention(thin) () -> Int
266
+ // CHECK: // function_ref computeInt()
267
+ // CHECK: function_ref @$s17property_wrappers10computeIntSiyF : $@convention(thin) () -> Int
268
+ }
269
+
270
+ @propertyWrapper
271
+ struct WrapperWithNonEscapingAutoclosure < V> {
272
+ var wrappedValue : V
273
+ init ( wrappedValue: @autoclosure ( ) -> V ) {
274
+ self . wrappedValue = wrappedValue ( )
275
+ }
276
+ }
277
+
278
+ struct UseWrapperWithNonEscapingAutoclosure {
279
+ @WrapperWithNonEscapingAutoclosure var foo : Int
280
+
281
+ // Memberwise init should take an Int arg, not a closure
282
+ // CHECK: // UseWrapperWithNonEscapingAutoclosure.init(foo:)
283
+ // CHECK: sil hidden [ossa] @$s17property_wrappers36UseWrapperWithNonEscapingAutoclosureV3fooACSi_tcfC : $@convention(method) (Int, @thin UseWrapperWithNonEscapingAutoclosure.Type) -> UseWrapperWithNonEscapingAutoclosure
284
+ }
285
+
246
286
struct UseStatic {
247
287
// CHECK: sil hidden [ossa] @$s17property_wrappers9UseStaticV12staticWibbleSaySiGvgZ
248
288
// CHECK: sil private [global_init] [ossa] @$s17property_wrappers9UseStaticV13_staticWibble33_{{.*}}4LazyOySaySiGGvau
@@ -334,6 +374,24 @@ func testComposition() {
334
374
_ = CompositionMembers ( p1: nil )
335
375
}
336
376
377
+ @propertyWrapper
378
+ struct WrapperWithAutoclosure < V> {
379
+ var wrappedValue : V
380
+ init ( wrappedValue: @autoclosure @escaping ( ) -> V ) {
381
+ self . wrappedValue = wrappedValue ( )
382
+ }
383
+ }
384
+
385
+ struct CompositionWithAutoclosure {
386
+ @WrapperA @WrapperB @WrapperWithAutoclosure var p1 : Int
387
+ @WrapperA @WrapperWithAutoclosure @WrapperB var p2 : Int
388
+ @WrapperWithAutoclosure @WrapperA @WrapperB var p3 : Int
389
+
390
+ // In the memberwise init, only p1 should be a closure - p2 and p3 should be just Int
391
+ // CompositionWithAutoclosure.init(p1:p2:p3:)
392
+ // CHECK-LABEL: sil hidden [ossa] @$s17property_wrappers26CompositionWithAutoclosureV2p12p22p3ACSiyXA_S2itcfC : $@convention(method) (@owned @callee_guaranteed () -> Int, Int, Int, @thin CompositionWithAutoclosure.Type) -> CompositionWithAutoclosure
393
+ }
394
+
337
395
// Observers with non-default mutatingness.
338
396
@propertyWrapper
339
397
struct NonMutatingSet < T> {
0 commit comments