Skip to content

Missing hashCode definitions #706

Open
@fpoli

Description

@fpoli

The Scalastyle linter complains about missing hashCode definitions in Silver. I'm not sure if we did that intentionally but it seems worth double-checking, adding a comment to Silver if there is nothing to fix.

Defining either equals() or hashCode() in a class without defining the other is a known source of bugs. Usually, when you define one, you should also define the other.

Further Reading: Scalastyle - EqualsHashCode

case class NodeEq(node: Rewritable) {
override def equals(that: Any): Boolean = that match {
case req: NodeEq => this.node eq req.node
case ref: AnyRef => this.node eq ref
case _ => false
}
}

trait StructuralEquality { self: AnyRef =>
protected val equalityDefiningMembers: Seq[Any]
override val hashCode = generateHashCode(equalityDefiningMembers)
override def equals(other: Any) = (
this.eq(other.asInstanceOf[AnyRef])
|| (other match {
case se: StructuralEquality if this.getClass.eq(se.getClass) =>
equalityDefiningMembers == se.equalityDefiningMembers
case _ => false
}))
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions