Conversation
|
Which kind of subclassing should be allowed ( Unknown -> *
Immutable -> Immutable
ImmutableWithMutableSubclass -> ImmutableWithMutableSubclass + Mutable
Mutable -> Mutable
InteriorMutable -> InteriorMutable + MainThreadOnly
MainThreadOnly -> MainThreadOnly |
71e04b1 to
d40b0f8
Compare
d40b0f8 to
3730c60
Compare
|
I'm wondering how to assign things in |
|
Also, Though perhaps we can still use it in e.g. |
|
I considered that it may be favourable to allow changing the class kind from the default to Changing from the default |
974e14a to
d520e53
Compare
0a5e889 to
708cef4
Compare
0d36fdd to
4b29af9
Compare
0c2e3b8 to
5552fdf
Compare
1434eb6 to
01e2f42
Compare
a7080d1 to
f08ab2b
Compare
Add associated type `ClassType::Mutability`, which describes the mutability of an object. This replaces the `Ownership` parameter in `Id<T, O>` (so we're moving the mutability/ownership specification from use site to declaration site, which is a bit more restrictive, but much more succinct, as well as being easier to understand and harder to make mistakes). Along with this, we can also finally fix `NSCopying` and `NSMutableCopying` in a way that `ProtocolObject<dyn NSCopying>` is allowed.
These are clearly unsound, and even though the error messages are pretty terrible, it is still better to disallow them.
|
Tagging @simlay, @silvanshade and @mwcampbell as you might want to be notified of this change: The changelog should contain migration instructions, but please let me know if you run into any issues! The change is primarily done because people (including myself) keep wanting to use |
Add associated type
ClassType::Mutability, which describes the mutability of an object. This replaces theOwnershipparameter inId<T, O>(so we're moving the mutability/ownership specification from use site to declaration site, which is a bit more restrictive, but much more succinct, as well as being easier to understand and harder to make mistakes).Along with this, we can also finally fix
NSCopyingandNSMutableCopyingin a way thatProtocolObject<dyn NSCopying>is allowed.The rough idea was initially described in #399 (comment), see the code and changelog for details on how the exact design turned out.
Id::retainsafer #399 by creatingClassType::retain, which is safe for certain classes.Ownershiptype on generics.NSCopyingandNSMutableCopying#401 by removing the associated types fromNSCopyingandNSMutableCopying, and instead having that data encoded in the associated typeClassType::Mutability.Id<T> -> &mut TwhenTis not mutable. The remaining part in that (proper main thread safety) is tracked in Sendability attributes #359.