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

Make generic types' PartialEq, Eq, Hash and Debug implementations more flexible #652

Open
madsmtm opened this issue Sep 18, 2024 · 0 comments
Labels
A-framework Affects the framework crates and the translator for them enhancement New feature or request

Comments

@madsmtm
Copy link
Owner

madsmtm commented Sep 18, 2024

We should consider implementing PartialEq, Eq, Hash and Debug on generic collections for all T: Message, instead of T: $trait + Message as is currently done via. #[derive].

Notes:

  • Swift doesn't enable generics for NSArray, so it is comparable even if it contains AnyObject. It will try to call isEqual: on the elements below it, and that will expectedly crash if the type doesn't implement an isEqual: method, just like it does if you try to use the built-in conversion operators.
  • Swift allows e.g. NSCache<AnyObject, AnyObject> to be hashable and comparable, since that type just does pointer comparison.
  • The user can convert NSArray<AnyObject> -> NSObject, and compare those.
  • This is not a soundness issue, the question is where it lies on the correctness vs. convenience scale?

Related to #559, #562 and #267.

@madsmtm madsmtm added enhancement New feature or request A-framework Affects the framework crates and the translator for them labels Sep 18, 2024
@madsmtm madsmtm added this to the Polish frameworks milestone Sep 18, 2024
@madsmtm madsmtm changed the title Make generic types' PartialEq, Eq and Hash implementations more flexible Make generic types' PartialEq, Eq, Hash and Debug implementations more flexible Sep 18, 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 enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant