Hi,
I have the following snippet
final class A {
let b: B
init(b: B) {
self.b = b
}
func execute1() async {
await b.doSomething() // error: Sending 'self.b' risks causing data races
}
func execute2() async {
let doSomething = b.doSomething
await doSomething() // This is ok
}
}
final class B {
@MainActor func doSomething() async {
print("did something")
}
}
I cannot understand why execute2
method compiles successfully.
I would have expected to encounter the same error as in execute1
method.