Skip to content

Locked shouldn't be a property wrapper. #185

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 16, 2024

Conversation

grynspan
Copy link
Contributor

@grynspan grynspan commented Jan 16, 2024

Property wrappers, when used as static properties, are inherently concurrency-unsafe (because they must be var, not let.) Discussed with the core Swift folks; this PR removes property wrapper "conformance" from Locked, adds RawRepresentable to replace it, and modifies call sites as appropriate.

Resolves rdar://121054518.

Checklist:

  • Code and documentation should follow the style of the Style Guide.
  • If public symbols are renamed or modified, DocC references should be updated.

Property wrappers, when used as static properties, are inherently concurrency-unsafe (because they must be `var`, not `let`.) Discussed with the core Swift folks; this PR removes property wrapper "conformance" from `Locked`, adds `RawRepresentable` to replace it, and modifies call sites as appropriate.

Resolves rdar://121054518.
@grynspan
Copy link
Contributor Author

@swift-ci please test

1 similar comment
@grynspan
Copy link
Contributor Author

@swift-ci please test

@grynspan
Copy link
Contributor Author

@swift-ci please clean test

@grynspan grynspan self-assigned this Jan 16, 2024
@grynspan grynspan added concurrency 🔀 Swift concurrency/sendability issues workaround Workaround for an issue in another component (may need to revert later) labels Jan 16, 2024
@@ -25,7 +25,6 @@ private import TestingInternals
/// - Bug: The state protected by this type should instead be protected using
/// actor isolation, but actor-isolated functions cannot be called from
/// synchronous functions. ([83888717](rdar://83888717))
@propertyWrapper
struct Locked<T>: @unchecked Sendable where T: Sendable {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still think the single word "Locked" is a good name for this type, given that it's no longer a property wrapper?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine, because you'd pronounce it Locked<Int> or similar. I'm open to alternatives (LockedValue<Int> sounds silly to me though.)

@grynspan
Copy link
Contributor Author

@swift-ci please test

@grynspan
Copy link
Contributor Author

CI failures are unrelated to this PR and are being tracked elsewhere; changes have been verified at desk on Linux and macOS.

@grynspan grynspan merged commit e981e3e into main Jan 16, 2024
@grynspan grynspan deleted the jgrynspan/121054518-locked-no-property-wrapper branch January 16, 2024 19:11
grynspan added a commit that referenced this pull request Jan 17, 2024
Follow-up to #185. I missed a use of `wrappedValue` and because our CI is broken, I didn't notice the failure.
grynspan added a commit that referenced this pull request Jan 17, 2024
Follow-up to #185. I missed a use of `wrappedValue` and because our CI is broken, I didn't notice the failure.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
concurrency 🔀 Swift concurrency/sendability issues workaround Workaround for an issue in another component (may need to revert later)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants