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-complete-note@+1 3{{class 'NotSendable' does not conform to the 'Sendable' protocol}}
22
+
classNotSendable{
23
+
varx:Int=0
24
+
25
+
@MyActorinit(){
26
+
MyActor.ns =self
27
+
}
28
+
29
+
init(x:Int){
30
+
self.x = x
31
+
}
32
+
33
+
@MyActorfunc stash(){
34
+
MyActor.ns =self
35
+
}
36
+
}
37
+
38
+
@MyActorfunc exhibitRace1()async{
39
+
letns=NotSendable(x:0)
40
+
MyActor.ns = ns
41
+
42
+
// expected-region-isolation-warning@+1 {{call site passes `self` or a non-sendable argument of this function to another thread, potentially yielding a race with the caller; this is an error in Swift 6}}
43
+
await{@YourActorin
44
+
// expected-complete-warning@+1 {{capture of 'ns' with non-sendable type 'NotSendable' in an isolated closure; this is an error in Swift 6}}
45
+
YourActor.ns = ns
46
+
}()
47
+
48
+
awaitwithTaskGroup(of:Void.self){
49
+
$0.addTask{
50
+
awaitMyActor.ohNo()
51
+
}
52
+
53
+
$0.addTask{
54
+
awaitYourActor.ohNo()
55
+
}
56
+
}
57
+
}
58
+
59
+
@MyActorfunc exhibitRace2()async{
60
+
letns=NotSendable(x:0)
61
+
ns.stash()
62
+
63
+
// FIXME: Region isolation should diagnose this (https://github.com/apple/swift/issues/71533)
64
+
await{@YourActorin
65
+
// expected-complete-warning@+1 {{capture of 'ns' with non-sendable type 'NotSendable' in an isolated closure; this is an error in Swift 6}}
66
+
YourActor.ns = ns
67
+
}()
68
+
69
+
awaitwithTaskGroup(of:Void.self){
70
+
$0.addTask{
71
+
awaitMyActor.ohNo()
72
+
}
73
+
74
+
$0.addTask{
75
+
awaitYourActor.ohNo()
76
+
}
77
+
}
78
+
}
79
+
80
+
@MyActorfunc exhibitRace3()async{
81
+
letns=NotSendable()
82
+
83
+
// FIXME: Region isolation should diagnose this (https://github.com/apple/swift/issues/71533)
84
+
await{@YourActorin
85
+
// expected-complete-warning@+1 {{capture of 'ns' with non-sendable type 'NotSendable' in an isolated closure; this is an error in Swift 6}}
0 commit comments