-
Notifications
You must be signed in to change notification settings - Fork 21
value classes allow equals and hashCode overrides via inherited trait #6534
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
Comments
Imported From: https://issues.scala-lang.org/browse/SI-6534?orig=1 |
@paulp said: |
@adriaanm said: |
@odersky said: This is a fairly easy diagnosis and fix: If you look at the generated code after post-erasure you see that an equals on a value class is replaced by the equals on the underlying object. The same optimization is not done for hashcode. There are two possible fixes:
I would vote for 2), which should be really easy to implement. Thanks |
@adriaanm said (edited on Oct 24, 2012 5:06:25 PM UTC): Can we make a list of all the ways in which we had to restrict value classes because of current implementation restrictions? I agree it's not a decision we should take lightly, but I feel the burden is on the extension to prove it's worth it. Also, implicit classes that directly extend AnyVal should be supported, but maybe anything beyond directly extending AnyVal should be considered experimental for now. |
@paulp said: https://github.com/paulp/scala/commits/issue/6534 The problem, which is what had me asking about moving equals earlier, is that it means a number of things no longer compile. So that's the rest of the changes. |
@paulp said: |
This is true of 2.10.0-RC1, which is not listed as a valid version.
But if an override is inherited, we get two different wrong behaviors: in the case of equals, no error is issued and it is ignored. In the case of hashCode, no error is issued and it is used.
The text was updated successfully, but these errors were encountered: