Skip to content
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

Sendable conformance for Key #167

Closed
Wouter01 opened this issue Feb 13, 2024 · 0 comments
Closed

Sendable conformance for Key #167

Wouter01 opened this issue Feb 13, 2024 · 0 comments

Comments

@Wouter01
Copy link
Contributor

Swift 5.10 adds new warnings related to strict concurrency. The Defaults.Key class currently lacks Sendable conformance, generating lots of warnings of the following kind when defining keys:

Static property 'someKey' is not concurrency-safe because it is not either conforming to 'Sendable' or isolated to a global actor; this is an error in Swift 6

The most logical thing would be to make Key a struct instead of a class, but I'm assuming inheritance is needed to get the current static property behavior. I'm not sure, but I think it's safe to add @unchecked Sendable conformance to _AnyKey. Checked Sendable conformance will give a warning as the class is not final, and UserDefaults is not marked Sendable. The docs state that it is thread safe though, making me believe adding @unchecked Sendable is fine. The _AnyKey class and Key class contain no mutable state, which is also fine for Sendable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant