-
Notifications
You must be signed in to change notification settings - Fork 50
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
Fix support for non-final classes in AtomicReference #58
Conversation
@swift-ci test |
Swift 5.6/7 generates new compiler warnings when non-final classes conform to `AtomicReference`. The warnings are pointing out a real design issue: Self is covariant in protocols, but we intend atomic operations to always deal with the base class rather than individual subclasses. Add a new associated type requirement to AtomicValue to represent the actual type that originally conformed to the protocol, and add explicit same-type requirements to clients to ensure they aren’t asked to return a subclass. Unfortunately, this change is source breaking: ``` class Base: AtomicReference {} class Derived: Base {} let ref = ManagedAtomic<Derived?>(nil) // before: OK // after: 'ManagedAtomic' requires the types 'Derived' and 'Base' be equivalent ```
263c074
to
4586994
Compare
4586994
to
5730529
Compare
@swift-ci test |
The source breakage seems mostly theoretical; it feels like the risk may be low enough to ship this in a minor release, especially since the compiler warning in 5.7 is highlighting a real correctness issue. (If it turns out this is too optimistic, then we might be able to do something about it, either by continuing to allow broken code in Swift 5.6 (only rejecting it in 5.7), or by tweaking |
@swift-ci test |
@swift-ci test |
@swift-ci test macOS platform |
Oh, a fix for that is in #73. |
@swift-ci test |
Swift 5.6/7 generates new compiler warnings when non-final classes conform to
AtomicReference
. The warnings are pointing out a real design issue: Self is covariant in protocols, but we intend atomic operations to always deal with the base class rather than individual subclasses.Add a new associated type requirement to AtomicValue to represent the actual type that originally conformed to the protocol, and add explicit same-type requirements to clients to ensure they aren’t asked to return a subclass.
Unfortunately, this change is source breaking:
Checklist