- Notifications
You must be signed in to change notification settings - Fork3.1k
Compare productPrefix in synthetic case class canEqual#10859
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
lrytz commentedSep 10, 2024
(should forward-port/report to Scala 3 once approved) |
cd7b384 to7315f51Compareretronym commentedSep 11, 2024
👍🏽 for the |
Since 2.13, case class `hashCode` mixes in the hash code of the`productPrefix` string. The synthetic `equals` method has fallenout of sync in that regard, so two instances can be equal but havedifferent hash codes.This commit changes the synthetic `canEqual` method to also comparethe `productPrefix` of the two instances.
deprecatedOverriding to synthetic case classproductPrefixSethTisue commentedSep 15, 2024
@lrytz do we need to release-note this, might it cause mysterious breakage? |
lrytz commentedSep 16, 2024
Yes, it changes case class equality. That is |
SethTisue commentedSep 17, 2024
we'll need a comparable PR on the Scala 3 side, yes? |
lrytz commentedSep 17, 2024
Yes. I can submit it there to probe what the 3 folks think about the semantic change. |
SethTisue commentedNov 6, 2024
@lrytz where does this stand, after the discussion onscala/scala3#21606 ? |
Uh oh!
There was an error while loading.Please reload this page.
Since 2.13, case class
hashCodemixes in the hash code of theproductPrefixstring. The syntheticequalsmethod has fallenout of sync in that regard, so two instances can be equal but have
different hash codes.
This commit changes the synthetic
canEqualmethod to also comparethe
productPrefixof the two instances.Fixesscala/bug#13033