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
[sending] Just like @sendable, sending stops isolation inference along DeclContexts.
Without this, we were hitting weird behaviors in flow_isolation.swift only when
compiling in Swift 5 mode.
Consider the following example:
```
func fakeTask(@_inheritActorContext _ x: sending @escaping () async -> ()) {}
actor MyActor {
var x: Int = 5
var y: Int = 6
var hax: MyActor? = nil
init() {
fakeTask {
// Warning! You can remove await
// Error! Cannot access actor state in nonisolated closure.
_ = await self.hax
}
}
}
```
The reason why this was happening is that we were not understanding that the
closure passed to fakeTask is not part of the init and has different isolation
from the init (it is nonisolated but does not have access to the init's state).
This then caused us to exit early and not properly process the isolation
crossing point there.
Now, we properly understand that a sending inheritActorContext closure (just
like an @sendable closure) has this property in actor initializers.
0 commit comments