@@ -12,14 +12,77 @@ func take(iso: (any Actor)?) {}
1212// CHECK-LABEL: // nonisolatedNonsending()
1313// CHECK-NEXT: // Isolation: caller_isolation_inheriting
1414// CHECK-NEXT: sil hidden @$s39isolated_nonsending_isolation_macro_sil21nonisolatedNonsendingyyYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional<any Actor>) -> () {
15- // CHECK: bb0(%0 : $Optional<any Actor>):
16- // CHECK-NEXT: hop_to_executor %0 // id: %1
17- // CHECK-NEXT: retain_value %0 // id: %2
18- // CHECK-NEXT: debug_value %0, let, name "iso" // id: %3
19- // CHECK-NEXT: // function_ref take(iso:)
20- // CHECK-NEXT: %4 = function_ref @$s39isolated_nonsending_isolation_macro_sil4take3isoyScA_pSg_tF : $@convention(thin) (@guaranteed Optional<any Actor>) -> () // user: %5
21- // CHECK-NEXT: %5 = apply %4(%0) : $@convention(thin) (@guaranteed Optional<any Actor>) -> ()
22- // CHECK-NEXT: release_value %0 // id: %6
23- // CHECK-NEXT: %7 = tuple () // user: %8
24- // CHECK-NEXT: return %7 // id: %8
25- // CHECK-NEXT: } // end sil function '$s39isolated_nonsending_isolation_macro_sil21nonisolatedNonsendingyyYaF'
15+ // CHECK: bb0([[ACTOR:%.*]] : $Optional<any Actor>):
16+ // CHECK: hop_to_executor [[ACTOR]]
17+ // CHECK: retain_value [[ACTOR]]
18+ // CHECK: debug_value [[ACTOR]], let, name "iso"
19+ // CHECK: [[FUNC:%.*]] = function_ref @$s39isolated_nonsending_isolation_macro_sil4take3isoyScA_pSg_tF : $@convention(thin) (@guaranteed Optional<any Actor>) -> ()
20+ // CHECK: apply [[FUNC]]([[ACTOR]]) : $@convention(thin) (@guaranteed Optional<any Actor>) -> ()
21+ // CHECK: release_value [[ACTOR]]
22+ // CHECK: } // end sil function '$s39isolated_nonsending_isolation_macro_sil21nonisolatedNonsendingyyYaF'
23+
24+ // Check that we emit #isolation correctly in closures.
25+ // CHECK-LABEL: // closure #1 in containsClosure()
26+ // CHECK-NEXT: // Isolation: caller_isolation_inheriting
27+ // CHECK: bb0(%0 : $Optional<any Actor>):
28+ // CHECK-NEXT: // function_ref take(iso:)
29+ // CHECK-NEXT: [[FN:%.*]] = function_ref @
30+ // CHECK-NEXT: apply [[FN]](%0)
31+ func containsClosure( ) {
32+ let closure : nonisolated( nonsending ) ( ) async -> Void = {
33+ take ( iso: #isolation)
34+ }
35+ }
36+
37+ // Check that we emit #isolation correctly in defer bodies.
38+ nonisolated ( nonsending)
39+ func hasDefer( ) async {
40+ defer {
41+ take ( iso: #isolation)
42+ }
43+ do { }
44+ }
45+ // CHECK-LABEL: sil hidden @$s39isolated_nonsending_isolation_macro_sil8hasDeferyyYaF :
46+ // CHECK: bb0(%0 : $Optional<any Actor>):
47+ // CHECK: // function_ref $defer
48+ // CHECK-NEXT: [[DEFER:%.*]] = function_ref
49+ // CHECK-NEXT: apply [[DEFER]](%0)
50+
51+ // CHECK-LABEL: // $defer #1 () in hasDefer()
52+ // CHECK-NEXT: // Isolation: caller_isolation_inheriting
53+ // CHECK: bb0(%0 : $Optional<any Actor>):
54+ // CHECK-NEXT: // function_ref take(iso:)
55+ // CHECK-NEXT: [[FN:%.*]] = function_ref @
56+ // CHECK-NEXT: apply [[FN]](%0)
57+
58+ // Check that we emit #isolation correctly in nested defer bodies.
59+ nonisolated ( nonsending)
60+ func hasNestedDefer( ) async {
61+ defer {
62+ defer {
63+ take ( iso: #isolation)
64+ }
65+ do { }
66+ }
67+ do { }
68+ }
69+
70+ // CHECK-LABEL: sil hidden @$s39isolated_nonsending_isolation_macro_sil14hasNestedDeferyyYaF :
71+ // CHECK: bb0(%0 : $Optional<any Actor>):
72+ // CHECK: // function_ref $defer #1 () in hasNestedDefer()
73+ // CHECK-NEXT: [[DEFER:%.*]] = function_ref
74+ // CHECK-NEXT: apply [[DEFER]](%0)
75+
76+ // CHECK-LABEL: // $defer #1 () in hasNestedDefer()
77+ // CHECK-NEXT: // Isolation: caller_isolation_inheriting
78+ // CHECK: bb0(%0 : $Optional<any Actor>):
79+ // CHECK: // function_ref $defer #1 () in $defer #1 () in hasNestedDefer()
80+ // CHECK-NEXT: [[DEFER:%.*]] = function_ref
81+ // CHECK-NEXT: apply [[DEFER]](%0)
82+
83+ // CHECK-LABEL: // $defer #1 () in $defer #1 () in hasNestedDefer()
84+ // CHECK-NEXT: // Isolation: caller_isolation_inheriting
85+ // CHECK: bb0(%0 : $Optional<any Actor>):
86+ // CHECK-NEXT: // function_ref take(iso:)
87+ // CHECK-NEXT: [[FN:%.*]] = function_ref @
88+ // CHECK-NEXT: apply [[FN]](%0)
0 commit comments