This isn't an area I understand very well. But it seems like nonisolated property wrappers should be possible if the underlying wrapper type is Sendable.
@propertyWrapper
struct Wrapped<T: Sendable>: Sendable {
var wrappedValue: T
init(wrappedValue: T) {
self.wrappedValue = wrappedValue
}
}
actor MyActor {
// if you can write this...
nonisolated var computedValue: Int {
get {
0
}
set {
// ... even if it tricky to implement
}
}
// shouldn't you be able to write this
// if the wrapper is Sendable?
@Wrapped nonisolated var wrappedValue: Int = 0
}
Proposed solution
I think this code should be accepted. As is, it produces an error:
error: 'nonisolated' is not supported on properties with property wrappers
Motivation
This isn't an area I understand very well. But it seems like nonisolated property wrappers should be possible if the underlying wrapper type is
Sendable
.Proposed solution
I think this code should be accepted. As is, it produces an error:
error: 'nonisolated' is not supported on properties with property wrappers
Alternatives considered
No response
Additional information
No response