@@ -39,7 +39,7 @@ sil @constructSendableKlass : $@convention(thin) () -> @owned SendableKlass
39
39
40
40
sil @transferNonSendableKlass : $@convention(thin) @async (@guaranteed NonSendableKlass) -> ()
41
41
sil @useNonSendableKlass : $@convention(thin) (@guaranteed NonSendableKlass) -> ()
42
- sil @constructNonSendableKlass : $@convention(thin) () -> @owned NonSendableKlass
42
+ sil @initNonSendableKlass : $@convention(thin) () -> @owned NonSendableKlass
43
43
44
44
sil @transferIndirect : $@convention(thin) @async <τ_0_0> (@in_guaranteed τ_0_0) -> ()
45
45
sil @useIndirect : $@convention(thin) <τ_0_0> (@in_guaranteed τ_0_0) -> ()
@@ -58,6 +58,7 @@ protocol P {
58
58
59
59
sil @initP : $@convention(thin) () -> @owned P
60
60
sil @transferP : $@async @convention(thin) (@guaranteed P) -> ()
61
+ sil @useP : $@convention(thin) (@in_guaranteed P) -> ()
61
62
62
63
protocol PAnyObject : AnyObject {}
63
64
@@ -67,6 +68,10 @@ sil @transferPAnyObject : $@async @convention(thin) (@guaranteed PAnyObject) ->
67
68
sil @usePAnyObjectWeak : $@convention(thin) (@guaranteed @sil_weak Optional<PAnyObject>) -> ()
68
69
sil @usePAnyObject : $@convention(thin) (@guaranteed Optional<PAnyObject>) -> ()
69
70
71
+ extension NonSendableKlass : P {
72
+ func doSomething()
73
+ }
74
+
70
75
/////////////////
71
76
// MARK: Tests //
72
77
/////////////////
@@ -172,3 +177,21 @@ bb0:
172
177
%9999 = tuple ()
173
178
return %9999 : $()
174
179
}
180
+
181
+ sil [ossa] @test_init_existential_value : $@async @convention(thin) () -> () {
182
+ bb0:
183
+ %f = function_ref @initNonSendableKlass : $@convention(thin) () -> @owned NonSendableKlass
184
+ %1 = apply %f() : $@convention(thin) () -> @owned NonSendableKlass
185
+
186
+ %2 = function_ref @transferNonSendableKlass : $@convention(thin) @async (@guaranteed NonSendableKlass) -> ()
187
+ apply [caller_isolation=nonisolated] [callee_isolation=global_actor] %2(%1) : $@convention(thin) @async (@guaranteed NonSendableKlass) -> ()
188
+ // expected-warning @-1 {{transferring value of non-Sendable type 'NonSendableKlass' from nonisolated context to global actor '<null>'-isolated context; later accesses could race}}
189
+
190
+ %i = init_existential_value %1 : $NonSendableKlass, $NonSendableKlass, $P
191
+ %f2 = function_ref @useP : $@convention(thin) (@in_guaranteed P) -> ()
192
+ apply %f2(%i) : $@convention(thin) (@in_guaranteed P) -> () // expected-note {{access here could race}}
193
+ destroy_value %i : $P
194
+
195
+ %9999 = tuple ()
196
+ return %9999 : $()
197
+ }
0 commit comments