Open
Description
(Migrating details from the Swift Forums)
Description
When Targeted/Complete Sendable
checking is enabled, the compiler produces a warning for non-Sendable
types crossing actor boundaries as result values, even if the values are explicitly unused.
Steps to reproduce
Compile the following code with Swift 5.8:
@globalActor
final class SomeDedicatedActor {
actor Actor {}
static let shared = Actor()
}
@SomeDedicatedActor
func f() async -> [Any] {
// ...
}
@MainActor
func g() async {
// ⚠️ Non-sendable type '[Any]' returned by implicitly asynchronous call
// to global actor 'SomeDedicatedActor'-isolated function cannot cross
// actor boundary
_ = await f()
}
Expected behavior
I would expect Swift to
- Attempt to elide transferring the resulting value across actor boundaries, and release it on the original actor
- Avoid producing the diagnostic
Environment
- Swift version:
swift-driver version: 1.75.2 Apple Swift version 5.8 (swiftlang-5.8.0.124.2 clang-1403.0.22.11.100) Target: arm64-apple-macosx13.0
- Xcode version:
Xcode 14.3 Build version 14E222b