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

Hash code for None changes across JVM invocations #4752

Closed
scabug opened this issue Jul 1, 2011 · 2 comments
Closed

Hash code for None changes across JVM invocations #4752

scabug opened this issue Jul 1, 2011 · 2 comments
Assignees

Comments

@scabug
Copy link

scabug commented Jul 1, 2011

The hashCode for None changes across JVM invocations. This is because the hashCode method is not generated for case objects, so it uses the default java.lang.Object.hashCode implementation. case objects should have a hashCode method generated like is done for case classes.

Related: #1387

@scabug
Copy link
Author

scabug commented Jul 1, 2011

Imported From: https://issues.scala-lang.org/browse/SI-4752?orig=1
Reporter: @harrah
Affected Versions: 2.9.0

@scabug
Copy link
Author

scabug commented Jul 1, 2011

Commit Message Bot (anonymous) said:
(extempore in r25215) Stable hashCodes for case objects.
Somehow case objects fell through the cracks and have had
default hashCode implementations, leading to new hashCodes on
each jvm run. Now we use the productPrefix, and inline it
right into the bytecode.

scala> None.## == "None".##
res0: Boolean = true

Closes #4752, no review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants