Open lrytz opened 1 month ago
... somewhat related: value case classes don't take canEquals
into account when they should. It works for final case classes.
scala> case class VCC(x: Int) extends AnyVal { def canEqual(x: Any) = false }
class VCC
scala> VCC(1) == VCC(1)
val res0: Boolean = true
scala> final case class FCC(x: Int) { def canEqual(x: Any) = false }
class FCC
scala> FCC(1) == FCC(1)
val res2: Boolean = false
Fortunately,
equals
doesn't invokecanEqual
because the class is final (it's a value class) https://github.com/scala/scala/blob/v2.13.14/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala#L200.