amnaredo / test

0 stars 0 forks source link

Derive.TypeKey lacks hashCode implementation #153

Open amnaredo opened 2 years ago

amnaredo commented 2 years ago

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!!!

ID: 124 Original Author: ghik

amnaredo commented 2 years ago

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

Original Author: Voltir

amnaredo commented 2 years ago

This has happened, more or less

Original Author: lihaoyi

amnaredo commented 2 years ago

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 :)

Original Author: ghik