-
Notifications
You must be signed in to change notification settings - Fork 69
Making Id::retain safer #399
Copy link
Copy link
Closed
Labels
A-objc2Affects the `objc2`, `objc2-exception-helper` and/or `objc2-encode` cratesAffects the `objc2`, `objc2-exception-helper` and/or `objc2-encode` cratesenhancementNew feature or requestNew feature or request
Milestone
Description
For some things like NSMutableString (and by extension, NSString), calling Id::retain on &T cannot be safe, since there could be a mutable reference to it somewhere else in the program (and the lifetime is erased by calling Id::retain, that's kinda the whole point).
The solution there is to use NSCopying::copy to instead store a copy of your string (which is cheap when given &NSString, and correct when given &NSMutableString).
But for types like NSView and NSWindow, this is overly restrictive, since we know there can never be a mutable reference to these (they always use interior mutability); so perhaps we can make a trait for expressing this? (This comes up especially often in user-defined init methods).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-objc2Affects the `objc2`, `objc2-exception-helper` and/or `objc2-encode` cratesAffects the `objc2`, `objc2-exception-helper` and/or `objc2-encode` cratesenhancementNew feature or requestNew feature or request