Skip to content
Snippets Groups Projects
Commit 288ce349 authored by Etienne Kneuss's avatar Etienne Kneuss
Browse files

Fix Equality of Implies. Disambiguate other's hashCode a bit.

parent dddc291d
Branches
Tags
No related merge requests found
...@@ -127,7 +127,7 @@ object Trees { ...@@ -127,7 +127,7 @@ object Trees {
case _ => false case _ => false
}) })
override def hashCode: Int = tuple.hashCode + index.hashCode override def hashCode: Int = tuple.hashCode + index.hashCode + 1
} }
object MatchExpr { object MatchExpr {
...@@ -160,7 +160,7 @@ object Trees { ...@@ -160,7 +160,7 @@ object Trees {
case _ => false case _ => false
}) })
override def hashCode: Int = scrutinee.hashCode+cases.hashCode override def hashCode: Int = scrutinee.hashCode + cases.hashCode + 2
} }
sealed abstract class MatchCase extends Tree { sealed abstract class MatchCase extends Tree {
...@@ -236,7 +236,7 @@ object Trees { ...@@ -236,7 +236,7 @@ object Trees {
case _ => false case _ => false
}) })
override def hashCode: Int = exprs.hashCode override def hashCode: Int = exprs.hashCode + 3
} }
object Or { object Or {
...@@ -279,7 +279,7 @@ object Trees { ...@@ -279,7 +279,7 @@ object Trees {
case _ => false case _ => false
}) })
override def hashCode: Int = exprs.hashCode override def hashCode: Int = exprs.hashCode + 4
} }
object Iff { object Iff {
...@@ -304,7 +304,7 @@ object Trees { ...@@ -304,7 +304,7 @@ object Trees {
case _ => false case _ => false
}) })
override def hashCode: Int = left.hashCode + right.hashCode override def hashCode: Int = left.hashCode + right.hashCode + 5
} }
object Implies { object Implies {
...@@ -322,17 +322,13 @@ object Trees { ...@@ -322,17 +322,13 @@ object Trees {
class Implies(val left: Expr, val right: Expr) extends Expr with FixedType { class Implies(val left: Expr, val right: Expr) extends Expr with FixedType {
val fixedType = BooleanType val fixedType = BooleanType
// if(left.getType != BooleanType || right.getType != BooleanType) {
// println("culprits: " + left.getType + ", " + right.getType)
// assert(false)
// }
override def equals(that: Any): Boolean = (that != null) && (that match { override def equals(that: Any): Boolean = (that != null) && (that match {
case t: Iff => t.left == left case t: Implies => t.left == left && t.right == right
case _ => false case _ => false
}) })
override def hashCode: Int = left.hashCode + right.hashCode override def hashCode: Int = left.hashCode + right.hashCode + 6
} }
object Not { object Not {
...@@ -355,7 +351,7 @@ object Trees { ...@@ -355,7 +351,7 @@ object Trees {
case _ => false case _ => false
}) })
override def hashCode : Int = expr.hashCode ^ Int.MinValue override def hashCode : Int = expr.hashCode + 7
} }
object Equals { object Equals {
...@@ -390,7 +386,7 @@ object Trees { ...@@ -390,7 +386,7 @@ object Trees {
case _ => false case _ => false
}) })
override def hashCode: Int = left.hashCode+right.hashCode override def hashCode: Int = left.hashCode + right.hashCode + 8
} }
case class Variable(id: Identifier) extends Expr with Terminal { case class Variable(id: Identifier) extends Expr with Terminal {
...@@ -455,7 +451,7 @@ object Trees { ...@@ -455,7 +451,7 @@ object Trees {
case _ => false case _ => false
}) })
override def hashCode: Int = (classType, caseClass, selector).hashCode override def hashCode: Int = (classType, caseClass, selector).hashCode + 9
} }
/* Arithmetic */ /* Arithmetic */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment