You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// expected-note @-2 {{sending main actor-isolated 'x' to nonisolated global function 'useValueAsync' risks causing data races between nonisolated and main actor-isolated uses}}
50
66
}
51
67
68
+
func withCheckedContinuation_3a()async{
69
+
letx=awaitwithCheckedContinuation{ continuation in
70
+
letx=NonSendableKlass()
71
+
continuation.resume(returning: x)
72
+
// expected-error @-1 {{sending 'x' risks causing data races}}
73
+
// expected-note @-2 {{'x' used after being passed as a 'sending' parameter}}
74
+
useValue(x) // expected-note {{access can happen concurrently}}
75
+
}
76
+
77
+
// This is ok since x is disconnected.
78
+
awaituseValueAsync(x)
79
+
}
80
+
52
81
@MainActor
53
82
func withCheckedContinuation_4()async{
54
83
// x is main actor isolated since withCheckedContinuation is #isolated.
// expected-note @-2 {{sending main actor-isolated 'x' to nonisolated global function 'useValueAsync' risks causing data races between nonisolated and main actor-isolated uses}}
65
94
}
66
95
96
+
func withCheckedContinuation_4a()async{
97
+
// x is main actor isolated since withCheckedContinuation is #isolated.
98
+
lety=NonSendableKlass()
99
+
letx=awaitwithCheckedContinuation{ continuation in
100
+
continuation.resume(returning: y)
101
+
// expected-error @-1 {{sending 'y' risks causing data races}}
102
+
// expected-note @-2 {{task-isolated 'y' is passed as a 'sending' parameter}}
// expected-error @-1 {{sending 'x' risks causing data races}}
177
+
// expected-note @-2 {{'x' used after being passed as a 'sending' parameter}}
178
+
useValue(x) // expected-note {{access can happen concurrently}}
179
+
}
180
+
}
181
+
182
+
@MainActor
183
+
func withUnsafeContinuation_3()async{
184
+
// x is main actor isolated since withUnsafeContinuation is #isolated.
185
+
letx=awaitwithUnsafeContinuation{ continuation in
186
+
letx=NonSendableKlass()
187
+
continuation.resume(returning: x)
188
+
// expected-error @-1 {{sending 'x' risks causing data races}}
189
+
// expected-note @-2 {{'x' used after being passed as a 'sending' parameter}}
190
+
useValue(x) // expected-note {{access can happen concurrently}}
191
+
}
192
+
awaituseValueAsync(x)
193
+
// expected-error @-1 {{sending 'x' risks causing data races}}
194
+
// expected-note @-2 {{sending main actor-isolated 'x' to nonisolated global function 'useValueAsync' risks causing data races between nonisolated and main actor-isolated uses}}
195
+
}
196
+
197
+
func withUnsafeContinuation_3a()async{
198
+
letx=awaitwithUnsafeContinuation{ continuation in
199
+
letx=NonSendableKlass()
200
+
continuation.resume(returning: x)
201
+
// expected-error @-1 {{sending 'x' risks causing data races}}
202
+
// expected-note @-2 {{'x' used after being passed as a 'sending' parameter}}
203
+
useValue(x) // expected-note {{access can happen concurrently}}
204
+
}
205
+
awaituseValueAsync(x)
206
+
}
207
+
208
+
@MainActor
209
+
func withUnsafeContinuation_4()async{
210
+
// x is main actor isolated since withUnsafeContinuation is #isolated.
211
+
lety=NonSendableKlass()
212
+
letx=awaitwithUnsafeContinuation{ continuation in
213
+
continuation.resume(returning: y)
214
+
// expected-error @-1 {{sending 'y' risks causing data races}}
215
+
// expected-note @-2 {{main actor-isolated 'y' is passed as a 'sending' parameter}}
216
+
useValue(y)
217
+
}
218
+
awaituseValueAsync(x)
219
+
// expected-error @-1 {{sending 'x' risks causing data races}}
220
+
// expected-note @-2 {{sending main actor-isolated 'x' to nonisolated global function 'useValueAsync' risks causing data races between nonisolated and main actor-isolated uses}}
221
+
}
222
+
223
+
func withUnsafeContinuation_4a()async{
224
+
// x is main actor isolated since withUnsafeContinuation is #isolated.
225
+
lety=NonSendableKlass()
226
+
letx=awaitwithUnsafeContinuation{ continuation in
227
+
continuation.resume(returning: y)
228
+
// expected-error @-1 {{sending 'y' risks causing data races}}
229
+
// expected-note @-2 {{task-isolated 'y' is passed as a 'sending' parameter}}
0 commit comments