-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Open
Labels
actorFeature → concurrency: `actor` declarationsFeature → concurrency: `actor` declarationsactor 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.compilerThe Swift compiler itselfThe Swift compiler itselfconcurrencyFeature: umbrella label for concurrency language featuresFeature: umbrella label for concurrency language featuresproperty wrappersFeature: property wrappersFeature: property wrappers
Description
Previous ID | SR-16052 |
Radar | None |
Original Reporter | StarLard (JIRA User) |
Type | Bug |
Attachment: Download
Environment
Xcode 13.3
Swift 5.6
Additional Detail from JIRA
Votes | 0 |
Component/s | Compiler, swift |
Labels | Bug, Concurrency, PropertyWrappers |
Assignee | None |
Priority | Medium |
md5: f522783fd58bc1635562f6ecf2e3eca5
Issue Description:
Compiler produces an actor isolation violation error when referencing a wrapped property from a global actor isolated class' init or deinit methods. Using the long-form declaration of the property wrapper or forgoing the property wrapper does not trigger the violation. Using an actor type instead of a global actor isolated class also does not reproduce this error.
Error Reproduction Example:
@propertyWrapper struct Wrapped<Value> {
var wrappedValue: Value
init(wrappedValue: Value) {
self.wrappedValue = wrappedValue
}
}
@MainActor
class Example {
var notWrappedValue: Bool = true
@Wrapped
var wrappedValue: Bool = true
var wrappedValueLong: Wrapped<Bool> = Wrapped(wrappedValue: true)
nonisolated init() {
_ = self.notWrappedValue // Ok
_ = self.wrappedValueLong // Ok
_ = self.wrappedValue // Error: Property 'value' isolated to global actor 'MainActor' can not be referenced from a non-isolated synchronous context
}
deinit {
_ = self.notWrappedValue // Ok
_ = self.wrappedValueLong // Ok
_ = self.wrappedValue // Error: Property 'value' isolated to global actor 'MainActor' can not be referenced from this synchronous context
}
}
Metadata
Metadata
Assignees
Labels
actorFeature → concurrency: `actor` declarationsFeature → concurrency: `actor` declarationsactor 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.compilerThe Swift compiler itselfThe Swift compiler itselfconcurrencyFeature: umbrella label for concurrency language featuresFeature: umbrella label for concurrency language featuresproperty wrappersFeature: property wrappersFeature: property wrappers