迁移管理器/二进制兼容性:参考 private[this] 覆盖哈希码
Migration-Manager / binary compatibility: overriding hash-code with reference to private[this]
为什么要覆盖 hashCode
二进制不兼容的更改:
之前:
trait Foo extends Product
之后:
trait Foo extends Product {
private[this] lazy val _hashCode = ScalaRunTime._hashCode(this)
override def hashCode: Int = _hashCode
}
迁移管理器说:
[error] * synthetic method Foo$$_hashCode()Int in trait Foo is present only in current version
[error] filter with: ProblemFilters.exclude[ReversedMissingMethodProblem]("Foo.Foo$$_hashCode")
这真的是个问题吗?或者我可以通过此更改保持相同的次要版本吗?
不是直接的答案,但可以完全避免 private[this] lazy val
:
trait Foo extends Product {
override lazy val hashCode: Int = ScalaRunTime._hashCode(this)
}
到这里,米麻不怨。
为什么要覆盖 hashCode
二进制不兼容的更改:
之前:
trait Foo extends Product
之后:
trait Foo extends Product {
private[this] lazy val _hashCode = ScalaRunTime._hashCode(this)
override def hashCode: Int = _hashCode
}
迁移管理器说:
[error] * synthetic method Foo$$_hashCode()Int in trait Foo is present only in current version
[error] filter with: ProblemFilters.exclude[ReversedMissingMethodProblem]("Foo.Foo$$_hashCode")
这真的是个问题吗?或者我可以通过此更改保持相同的次要版本吗?
不是直接的答案,但可以完全避免 private[this] lazy val
:
trait Foo extends Product {
override lazy val hashCode: Int = ScalaRunTime._hashCode(this)
}
到这里,米麻不怨。