Closed
Description
Description
I'm not sure how it's possible that self
could be sent in this situation. The closures involved are not @Sendable
, so the isolation should never change.
- error: sending 'self' risks causing data races
- note: 'isolation'-isolated 'self' is captured by a actor-isolated closure. actor-isolated uses in closure may race against later nonisolated uses
Reproduction
class MyClass {
var handler: (@escaping () -> Void) -> Void = { _ in }
func doThing(isolation: isolated (any Actor)?) {
handler {
// error: sending 'self' risks causing data races
self.doOtherThing(isolation: isolation)
}
}
func doOtherThing(isolation: isolated (any Actor)?) {
}
}
Expected behavior
I would expect this to compile error-free.
Environment
swift-driver version: 1.115 Apple Swift version 6.0.2 (swiftlang-6.0.2.1.2 clang-1600.0.26.4)
Target: arm64-apple-macosx14.0
Additional information
No response