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
Copy file name to clipboardExpand all lines: test/Concurrency/sendable_checking.swift
+5-4Lines changed: 5 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -96,6 +96,8 @@ public actor MyActor: MyProto {
96
96
97
97
func g(ns1:NS1)async{
98
98
awaitnonisolatedAsyncFunc1(ns1) // expected-targeted-and-complete-warning{{passing argument of non-sendable type 'NS1' outside of actor-isolated context may introduce data races}}
99
+
// expected-tns-warning @-1 {{transferring 'ns1' may cause a race}}
100
+
// expected-tns-note @-2 {{transferring actor-isolated 'ns1' to nonisolated callee could cause races between nonisolated and actor-isolated uses}}
99
101
_ =awaitnonisolatedAsyncFunc2() // expected-warning{{non-sendable type 'NS1' returned by implicitly asynchronous call to nonisolated function cannot cross actor boundary}}
// expected-note@+1 2 {{consider making struct 'NotSendable' conform to the 'Sendable' protocol}}
356
357
structNotSendable:Equatable{}
357
358
358
-
// expected-warning@+2 2{{non-sendable type 'SynthesizedConformances.NotSendable' in asynchronous access to main actor-isolated property 'x' cannot cross actor boundary}}
359
-
// expected-note@+1 2{{in derived conformance to 'Equatable'}}
359
+
// expected-warning@+2 2{{main actor-isolated property 'x' can not be referenced from a non-isolated context}}
360
+
// expected-note@+1 2{{in static method '==' for derived conformance to 'Equatable'}}
// This test makes sure that we treat types with an unavailable Sendable
7
+
// conformance as being non-Sendable.
8
+
9
+
publicclassNonSendable{
10
+
func foo(){
11
+
}
12
+
}
13
+
14
+
@available(*, unavailable)
15
+
extensionNonSendable:Sendable{}
16
+
17
+
actorBar{
18
+
init(_ _:NonSendable){
19
+
}
20
+
func bar()async{
21
+
letns=NonSendable() // expected-note {{variable defined here}}
22
+
_ =Bar(ns) // expected-warning {{transferring 'ns' may cause a race}}
23
+
// TODO: This needs to be:
24
+
// disconnected 'ns' is transferred to actor-isolated callee. Later local uses could race with uses in callee.
25
+
// expected-note @-3 {{'ns' is transferred from actor-isolated caller to actor-isolated callee. Later uses in caller could race with potential uses in callee}}
26
+
ns.foo() // expected-note {{access here could race}}
0 commit comments