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

Derive.TypeKey lacks hashCode implementation #124

Closed
ghik opened this Issue Dec 4, 2015 · 3 comments

Comments

Projects
None yet
3 participants
@ghik
Copy link
Contributor

ghik commented Dec 4, 2015

Derive.TypeKey has equals overridden but does not properly override hashCode. This can lead to patologies like:

val tk1 = TypeKey(typeOf[String])
val tk2 = TypeKey(typeOf[java.lang.String])
tk1 == tk2 // true
tk1.hashCode == tk2.hashCode // false!!!
@Voltir

This comment has been minimized.

Copy link

Voltir commented Dec 23, 2015

I looked at this a bit and realized that I'm not actually sure what a proper hashcode would be.

@lihaoyi

This comment has been minimized.

Copy link
Owner

lihaoyi commented Jan 24, 2016

This has happened, more or less

@lihaoyi lihaoyi closed this Jan 24, 2016

@ghik

This comment has been minimized.

Copy link
Contributor

ghik commented Jan 25, 2016

I also saw shapeless implement Type-keyed maps. There was no hashCode implemented at all, but the consequences were avoided by using ListMap instead of HashMap :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment