Closed
Description
Description
I was trying to get around returning a non-Sendable type from a synchronous function. I thought I'd be able to use sending to deal with this, but it doesn't seem to work.
Reproduction
class NonSendable {}
@MainActor
func f() async {
async let x = g()
// error: non-sendable type 'NonSendable' returned by implicitly asynchronous call to nonisolated function cannot cross actor boundary
_ = await x
}
func g() -> sending NonSendable {
NonSendable()
}
await f()
Expected behavior
I would expect this to compile warning-free.
Environment
swift-driver version: 1.115 Apple Swift version 6.0 (swiftlang-6.0.0.9.11 clang-1600.0.26.2)
Target: arm64-apple-macosx14.0
Additional information
No response