-
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
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
For some things like
NSMutableString(and by extension,NSString), callingId::retainon&Tcannot be safe, since there could be a mutable reference to it somewhere else in the program (and the lifetime is erased by callingId::retain, that's kinda the whole point).The solution there is to use
NSCopying::copyto instead store a copy of your string (which is cheap when given&NSString, and correct when given&NSMutableString).But for types like
NSViewandNSWindow, 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-definedinitmethods).