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

Can methods taking AnyObject be safe? #562

Open
madsmtm opened this issue Jan 17, 2024 · 0 comments
Open

Can methods taking AnyObject be safe? #562

madsmtm opened this issue Jan 17, 2024 · 0 comments
Labels
A-framework Affects the framework crates and the translator for them

Comments

@madsmtm
Copy link
Owner

madsmtm commented Jan 17, 2024

Methods like NSAccessibilityElement::accessibilityElementWithRole_frame_label_parent or NSResponder::insertTab take &AnyObject.
This means that they can assume very little about the object, but that's usually fine, as it's only really used in user-implemented methods (I think?).

Can we allow such methods to be safe? What about if I were to pass a &NSMutableString? Would that still be safe because I/the method can't recover the mutable string, or would safety be broken here?


Related is methods like NSError::initWithDomain_code_userInfo or NSAttributedString::initWithString_attributes, which accept NSDictionary<SomeKey, AnyObject>, and expect the user to pass the correct type for a given key.
Does Foundation assert that the attributes are the correct type? If so, can we allow these methods to be safe?

@madsmtm madsmtm added the A-framework Affects the framework crates and the translator for them label Jan 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-framework Affects the framework crates and the translator for them
Projects
None yet
Development

No branches or pull requests

1 participant