-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Open
Labels
actor isolationFeature → concurrency: Actor isolationFeature → concurrency: Actor isolationcompilerThe Swift compiler itselfThe Swift compiler itselfconcurrencyFeature: umbrella label for concurrency language featuresFeature: umbrella label for concurrency language featuresfeatureA feature request or implementationA feature request or implementationproperty wrappersFeature: property wrappersFeature: property wrappersswift evolution proposal neededFlag → feature: A feature that warrants a Swift evolution proposalFlag → feature: A feature that warrants a Swift evolution proposal
Description
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
.
@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
Alternatives considered
No response
Additional information
No response
Metadata
Metadata
Assignees
Labels
actor isolationFeature → concurrency: Actor isolationFeature → concurrency: Actor isolationcompilerThe Swift compiler itselfThe Swift compiler itselfconcurrencyFeature: umbrella label for concurrency language featuresFeature: umbrella label for concurrency language featuresfeatureA feature request or implementationA feature request or implementationproperty wrappersFeature: property wrappersFeature: property wrappersswift evolution proposal neededFlag → feature: A feature that warrants a Swift evolution proposalFlag → feature: A feature that warrants a Swift evolution proposal