I am getting this warning with Xcode14 beta 4 (14A5284g) as well as the 5.7 snapshot from August 2nd:
actor Test {
@TaskLocal static var local: Int?
func run() async {
await Self.$local.withValue(42) { ⚠️
await work()
}
}
func work() async {
print("Hello \(Self.local ?? 0)")
}
}
await Test().run()
non-sendable type '() async throws -> ()' exiting actor-isolated context in call to non-isolated instance method 'withValue(_:operation:file:line:)' cannot cross actor boundary
I am not sure how to deal with this. Is this legal code and the diagnostic is wrong or am I mis-using task local values?