@@ -39,7 +39,7 @@ sil @constructSendableKlass : $@convention(thin) () -> @owned SendableKlass
3939
4040sil @transferNonSendableKlass : $@convention(thin) @async (@guaranteed NonSendableKlass) -> ()
4141sil @useNonSendableKlass : $@convention(thin) (@guaranteed NonSendableKlass) -> ()
42- sil @constructNonSendableKlass : $@convention(thin) () -> @owned NonSendableKlass
42+ sil @initNonSendableKlass : $@convention(thin) () -> @owned NonSendableKlass
4343
4444sil @transferIndirect : $@convention(thin) @async <τ_0_0> (@in_guaranteed τ_0_0) -> ()
4545sil @useIndirect : $@convention(thin) <τ_0_0> (@in_guaranteed τ_0_0) -> ()
@@ -58,6 +58,7 @@ protocol P {
5858
5959sil @initP : $@convention(thin) () -> @owned P
6060sil @transferP : $@async @convention(thin) (@guaranteed P) -> ()
61+ sil @useP : $@convention(thin) (@in_guaranteed P) -> ()
6162
6263protocol PAnyObject : AnyObject {}
6364
@@ -67,6 +68,10 @@ sil @transferPAnyObject : $@async @convention(thin) (@guaranteed PAnyObject) ->
6768sil @usePAnyObjectWeak : $@convention(thin) (@guaranteed @sil_weak Optional<PAnyObject>) -> ()
6869sil @usePAnyObject : $@convention(thin) (@guaranteed Optional<PAnyObject>) -> ()
6970
71+ extension NonSendableKlass : P {
72+ func doSomething()
73+ }
74+
7075/////////////////
7176// MARK: Tests //
7277/////////////////
@@ -172,3 +177,21 @@ bb0:
172177 %9999 = tuple ()
173178 return %9999 : $()
174179}
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