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
}
}
Attachment: Download
Environment
Xcode 13.3 Swift 5.6Additional Detail from JIRA
| | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler, swift | |Labels | Bug, Concurrency, PropertyWrappers | |Assignee | None | |Priority | Medium | md5: f522783fd58bc1635562f6ecf2e3eca5Issue 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: