-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
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
Description
Accessing a nonisolated(unsafe) var from an actor initializer gives a warning
Reproduction
actor A {
private nonisolated(unsafe) var child: B!
init() {
child = B(parent: self) // warning: cannot access property 'child' here in non-isolated initializer; this is an error in the Swift 6 language mode
}
}
actor B {
unowned nonisolated let parent: any Actor
init(parent: any Actor) {
self.parent = parent
}
}
the following workaround compiles without issue:
actor A {
private nonisolated(unsafe) var child: B!
init() {
let b = B(parent: self)
f(b)
}
nonisolated func f(_ b: B) {
child = b
}
}
actor B {
unowned nonisolated let parent: any Actor
init(parent: any Actor) {
self.parent = parent
}
}
Expected behavior
No warning
Environment
Godbolt nightly
Swift version 6.0-dev (LLVM 57699466ce1fb1c, Swift e373cae72967b82)
Target: x86_64-unknown-linux-gnu
Additional information
No response
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