-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Open
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.concurrencyFeature: umbrella label for concurrency language featuresFeature: umbrella label for concurrency language features
Description
Reproduction
Consider the following code, split in 2 modules:
// Module 1, compiled with Swift 5 and no strict concurrency checking:
public class A {
public init() {}
public func f(_ value: @escaping () -> Void) {
DispatchQueue.global().async { value() }
}
}
// Module 2, compiled with Swift 6:
import Module1
@MainActor
func g() {
A().f {
// This is assumed to be @MainActor isolated by default, leading to `dispatch_assert_queue` failed assertion
}
}Expected behavior
The code compiles with no warnings (because the closure passed to f is valid based on the definition), but it crashes at runtime due to it being inferred as @MainActor, and executing outside of it.
The closure shouldn't become @MainActor isolated implicitly just because it's called from a @MainActor method.
Environment
swift-driver version: 1.112.3 Apple Swift version 6.0 (swiftlang-6.0.0.6.8 clang-1600.0.23.1)
Target: arm64-apple-macosx14.0
Additional information
No response
groue and lzell
Metadata
Metadata
Assignees
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.concurrencyFeature: umbrella label for concurrency language featuresFeature: umbrella label for concurrency language features