1

Why is overriding hashCode a binary incompatible change:

Before:

trait Foo extends Product

After:

trait Foo extends Product {
  private[this] lazy val _hashCode = ScalaRunTime._hashCode(this)
  override def hashCode: Int = _hashCode
}

Migration-Manager says:

[error]  * synthetic method Foo$$_hashCode()Int in trait Foo is present only in current version
[error]    filter with: ProblemFilters.exclude[ReversedMissingMethodProblem]("Foo.Foo$$_hashCode")

Is this actually a problem? Or can I stay on the same minor version with this change?

0__
  • 66,707
  • 21
  • 171
  • 266

1 Answers1

0

Not a direct answer, but it's possibly to avoid the private[this] lazy val altogether:

trait Foo extends Product {
  override lazy val hashCode: Int = ScalaRunTime._hashCode(this)
}

Here, MiMa does not complain.

0__
  • 66,707
  • 21
  • 171
  • 266