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
[rbi] Make it so that we correctly do not error on uses of Sendable values that are projected from non-Sendable bases.
Specifically, we only do this if the base is a let or if it is a var but not
captured by reference.
rdar://149019222
(cherry picked from commit 23b6937)
// expected-tns-note @-1 {{sending task-isolated 'self.ns' to main actor-isolated global function 'transferToMain' risks causing data races between main actor-isolated and task-isolated uses}}
1969
1969
}
1970
1970
}
1971
+
1972
+
func mutableLocalCaptureDataRace()async{
1973
+
varx=0
1974
+
x =0
1975
+
_ = x
1976
+
1977
+
Task.detached{ x =1} // expected-tns-warning {{sending value of non-Sendable type '() async -> ()' risks causing data races}}
1978
+
// expected-tns-note @-1 {{Passing value of non-Sendable type '() async -> ()' as a 'sending' argument to static method 'detached(priority:operation:)' risks causing races in between local and caller code}}
1979
+
1980
+
x =2 // expected-tns-note {{access can happen concurrently}}
1981
+
}
1982
+
1983
+
func mutableLocalCaptureDataRace2()async{
1984
+
varx=0
1985
+
x =0
1986
+
1987
+
Task.detached{ x =1} // expected-tns-warning {{sending value of non-Sendable type '() async -> ()' risks causing data races}}
1988
+
// expected-tns-note @-1 {{Passing value of non-Sendable type '() async -> ()' as a 'sending' argument to static method 'detached(priority:operation:)' risks causing races in between local and caller code}}
1989
+
1990
+
print(x) // expected-tns-note {{access can happen concurrently}}
0 commit comments