-
Notifications
You must be signed in to change notification settings - Fork 49
Open
Description
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()orhashCode()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 | |
| } | |
| } |
silver/src/main/scala/viper/silver/utility/Common.scala
Lines 25 to 37 in c352aa5
| 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
Labels
No labels