-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed
Labels
actor isolationFeature → concurrency: Actor isolationFeature → concurrency: Actor isolationbugA 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
Description
see title
Reproduction
// swiftc -swift-version 6 -enable-upcoming-feature NonisolatedNonsendingByDefault -parse-as-library
actor MyActor {
// can also remove the explicit nonisolated(nonsending)
func test(_ closure: nonisolated(nonsending) () async -> Void) async {
await closure()
}
}
@concurrent
nonisolated func test() async {
let a = MyActor()
await a.test {
a.assertIsolated() // passes
let iso = #isolation
print(iso as Any) // nil
}
}
@main
enum App {
static func main() async {
await test()
}
}Expected behavior
the #isolation macro should resolve to the calling actor when used in a nonisolated(nonsending) closure.
Environment
Swift version 6.2-dev (LLVM 1b5a5a47cc92b04, Swift 7ec75e9)
Target: x86_64-unknown-linux-gnu
Additional information
original forum discussion: https://forums.swift.org/t/isolation-not-providing-the-correct-actor-in-closures-when-nonisolatednonsendingbydefault-is-enabled/81924
godbolt example: https://swift.godbolt.org/z/M5Tzxvhz1
Metadata
Metadata
Assignees
Labels
actor isolationFeature → concurrency: Actor isolationFeature → concurrency: Actor isolationbugA 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