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
// Just to show that without the transferring param, we generate diagnostics.
28
28
letx2=NonSendableCStruct()
29
29
lety2=returnUserDefinedFromGlobalFunction(x2)
30
-
awaittransferToMain(x2) // expected-error {{transferring 'x2' may cause a data race}}
31
-
// expected-note @-1 {{transferring disconnected 'x2' to main actor-isolated callee could cause races in between callee main actor-isolated and local nonisolated uses}}
32
-
useValue(y2) // expected-note {{use here could race}}
30
+
awaittransferToMain(x2) // expected-error {{sending 'x2' risks causing data races}}
31
+
// expected-note @-1 {{sending 'x2' to main actor-isolated global function 'transferToMain' risks causing data races between main actor-isolated and local nonisolated uses}}
// Just to show that without the transferring param, we generate diagnostics.
46
46
letx2=NSObject()
47
47
lety2=returnNSObjectFromGlobalFunction(x2)
48
-
awaittransferToMain(x2) // expected-error {{transferring 'x2' may cause a data race}}
49
-
// expected-note @-1 {{transferring disconnected 'x2' to main actor-isolated callee could cause races in between callee main actor-isolated and local nonisolated uses}}
50
-
useValue(y2) // expected-note {{use here could race}}
48
+
awaittransferToMain(x2) // expected-error {{sending 'x2' risks causing data races}}
49
+
// expected-note @-1 {{sending 'x2' to main actor-isolated global function 'transferToMain' risks causing data races between main actor-isolated and local nonisolated uses}}
// error: unexpected warning produced: transferring 'body' may cause a data race; this is an error in the Swift 6 language mode
21
+
// error: unexpected warning produced: transferring 'body' risks causing data races; this is an error in the Swift 6 language mode
22
22
// error: unexpected note produced: actor-isolated 'body' is captured by a actor-isolated closure. actor-isolated uses in closure may race against later nonisolated uses
Copy file name to clipboardExpand all lines: test/Concurrency/isolated_captures.swift
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -40,7 +40,7 @@ class NotSendable {
40
40
MyActor.ns = ns
41
41
42
42
await{@YourActorin
43
-
// expected-region-isolation-warning @+3 {{transferring 'ns' may cause a data race}}
43
+
// expected-region-isolation-warning @+3 {{sending 'ns' risks causing data races}}
44
44
// expected-region-isolation-note @+2 {{global actor 'MyActor'-isolated 'ns' is captured by a global actor 'YourActor'-isolated closure. global actor 'YourActor'-isolated uses in closure may race against later global actor 'MyActor'-isolated uses}}
45
45
// expected-complete-warning@+1 {{capture of 'ns' with non-sendable type 'NotSendable' in an isolated closure; this is an error in the Swift 6 language mode}}
46
46
YourActor.ns = ns
@@ -62,7 +62,7 @@ class NotSendable {
62
62
ns.stash()
63
63
64
64
await{@YourActorin
65
-
// expected-region-isolation-warning @+3 {{transferring 'ns' may cause a data race}}
65
+
// expected-region-isolation-warning @+3 {{sending 'ns' risks causing data races}}
66
66
// expected-region-isolation-note @+2 {{global actor 'MyActor'-isolated 'ns' is captured by a global actor 'YourActor'-isolated closure. global actor 'YourActor'-isolated uses in closure may race against later global actor 'MyActor'-isolated uses}}
67
67
// expected-complete-warning@+1 {{capture of 'ns' with non-sendable type 'NotSendable' in an isolated closure; this is an error in the Swift 6 language mode}}
68
68
YourActor.ns = ns
@@ -83,7 +83,7 @@ class NotSendable {
83
83
letns=NotSendable()
84
84
85
85
await{@YourActorin
86
-
// expected-region-isolation-warning @+3 {{transferring 'ns' may cause a data race}}
86
+
// expected-region-isolation-warning @+3 {{sending 'ns' risks causing data races}}
87
87
// expected-region-isolation-note @+2 {{global actor 'MyActor'-isolated 'ns' is captured by a global actor 'YourActor'-isolated closure. global actor 'YourActor'-isolated uses in closure may race against later global actor 'MyActor'-isolated uses}}
88
88
// expected-complete-warning@+1 {{capture of 'ns' with non-sendable type 'NotSendable' in an isolated closure; this is an error in the Swift 6 language mode}}
0 commit comments