@@ -431,4 +431,49 @@ func test_handling_of_nonmutating_set() {
431
431
self . count = 0
432
432
}
433
433
}
434
+
435
+ struct TestWithStored {
436
+ private var _count : Int
437
+ private var _text : String = " "
438
+
439
+ var count : Int {
440
+ @storageRestrictions ( initializes: _count)
441
+ init { _count = newValue }
442
+ get { _count }
443
+ nonmutating set { }
444
+ }
445
+
446
+ // CHECK-LABEL: sil private [ossa] @$s23assign_or_init_lowering32test_handling_of_nonmutating_setyyF14TestWithStoredL_V5countADSi_tcfC
447
+ // CHECK: [[SELF_REF:%.*]] = mark_uninitialized [rootself] %2
448
+ // CHECK: [[SELF:%.*]] = load [copy] {{.*}} : $*TestWithStored
449
+ // CHECK: [[SETTER_REF:%.*]] = function_ref @$s23assign_or_init_lowering32test_handling_of_nonmutating_setyyF14TestWithStoredL_V5countSivs : $@convention(method) (Int, @guaranteed TestWithStored) -> ()
450
+ // CHECK-NEXT: [[SETTER_CLOSURE:%.*]] = partial_apply [callee_guaranteed] [on_stack] [[SETTER_REF]]([[SELF]]) : $@convention(method) (Int, @guaranteed TestWithStored) -> ()
451
+ // CHECK-NEXT: assign_or_init [init] #<abstract function>TestWithStored.count, self [[SELF_REF]] : $*TestWithStored, value %0 : $Int, init {{.*}} : $@convention(thin) (Int) -> @out Int, set [[SETTER_CLOSURE]] : $@noescape @callee_guaranteed (Int) -> ()
452
+ // CHECK-NEXT: destroy_value [[SETTER_CLOSURE]] : $@noescape @callee_guaranteed (Int) -> ()
453
+ // CHECK-NEXT: destroy_value [[SELF]] : $TestWithStored
454
+ init ( count: Int ) {
455
+ self . count = count
456
+ }
457
+
458
+ // CHECK-LABEL: sil private [ossa] @$s23assign_or_init_lowering32test_handling_of_nonmutating_setyyF14TestWithStoredL_V5valueADSi_tcfC
459
+ // CHECK: [[SELF_REF:%.*]] = mark_uninitialized [rootself] %2
460
+ // CHECK: [[SELF:%.*]] = load [copy] {{.*}} : $*TestWithStored
461
+ //
462
+ // CHECK: [[SETTER_REF:%.*]] = function_ref @$s23assign_or_init_lowering32test_handling_of_nonmutating_setyyF14TestWithStoredL_V5countSivs : $@convention(method) (Int, @guaranteed TestWithStored) -> ()
463
+ // CHECK-NEXT: [[SETTER_CLOSURE:%.*]] = partial_apply [callee_guaranteed] [on_stack] [[SETTER_REF]]([[SELF]]) : $@convention(method) (Int, @guaranteed TestWithStored) -> ()
464
+ // CHECK-NEXT: assign_or_init [init] #<abstract function>TestWithStored.count, self [[SELF_REF]] : $*TestWithStored, value {{.*}} : $Int, init {{.*}} : $@convention(thin) (Int) -> @out Int, set [[SETTER_CLOSURE]] : $@noescape @callee_guaranteed (Int) -> ()
465
+ // CHECK-NEXT: destroy_value [[SETTER_CLOSURE]] : $@noescape @callee_guaranteed (Int) -> ()
466
+ // CHECK-NEXT: destroy_value [[SELF]] : $TestWithStored
467
+ //
468
+ // CHECK: [[SELF:%.*]] = load [copy] {{.*}} : $*TestWithStored
469
+ // CHECK: [[SETTER_REF:%.*]] = function_ref @$s23assign_or_init_lowering32test_handling_of_nonmutating_setyyF14TestWithStoredL_V5countSivs : $@convention(method) (Int, @guaranteed TestWithStored) -> ()
470
+ // CHECK-NEXT: [[SETTER_CLOSURE:%.*]] = partial_apply [callee_guaranteed] [on_stack] [[SETTER_REF]]([[SELF]]) : $@convention(method) (Int, @guaranteed TestWithStored) -> ()
471
+ // CHECK-NEXT: assign_or_init [set] #<abstract function>TestWithStored.count, self [[SELF_REF]] : $*TestWithStored, value %0 : $Int, init {{.*}} : $@convention(thin) (Int) -> @out Int, set [[SETTER_CLOSURE]] : $@noescape @callee_guaranteed (Int) -> ()
472
+ // CHECK-NEXT: destroy_value [[SETTER_CLOSURE]] : $@noescape @callee_guaranteed (Int) -> ()
473
+ // CHECK-NEXT: destroy_value [[SELF]] : $TestWithStored
474
+ init ( value: Int ) {
475
+ self . count = 0
476
+ self . count = value
477
+ }
478
+ }
434
479
}
0 commit comments