Open
Description
Description
It seems that a top-level closure without attributes is interpreted as both @MainActor
and non-@MainActor
.
Reproduction
enum Something {
@MainActor static var value = 0
}
let closure: () -> Void = {
Something.value += 1
}
let sendableClosure: @Sendable () -> Void = {
closure()
}
See also: https://forums.swift.org/t/why-can-a-sendable-closure-call-a-non-sendable-closure/79921
Expected behavior
The given code compiles (even in language mode 6) although it should not.
Environment
swift-driver version: 1.120.5 Apple Swift version 6.1.2 (swiftlang-6.1.2.1.2 clang-1700.0.13.5)
Target: arm64-apple-macosx15.0
Additional information
No response