-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Open
Labels
actorFeature → concurrency: `actor` declarationsFeature → concurrency: `actor` declarationsactor isolationFeature → concurrency: Actor isolationFeature → concurrency: Actor isolationcompilerThe Swift compiler itselfThe Swift compiler itselfconcurrencyFeature: umbrella label for concurrency language featuresFeature: umbrella label for concurrency language featuresfeatureA feature request or implementationA feature request or implementationimprovementswift 5.8type checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysis
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
Metadata
Metadata
Assignees
Labels
actorFeature → concurrency: `actor` declarationsFeature → concurrency: `actor` declarationsactor isolationFeature → concurrency: Actor isolationFeature → concurrency: Actor isolationcompilerThe Swift compiler itselfThe Swift compiler itselfconcurrencyFeature: umbrella label for concurrency language featuresFeature: umbrella label for concurrency language featuresfeatureA feature request or implementationA feature request or implementationimprovementswift 5.8type checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysis