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

Make sure all Expr are ==able

parent 9bdbf0e3
No related branches found
No related tags found
No related merge requests found
...@@ -113,6 +113,13 @@ object Trees { ...@@ -113,6 +113,13 @@ object Trees {
class MatchExpr(val scrutinee: Expr, val cases: Seq[MatchCase]) extends Expr with ScalacPositional { class MatchExpr(val scrutinee: Expr, val cases: Seq[MatchCase]) extends Expr with ScalacPositional {
def scrutineeClassType: ClassType = scrutinee.getType.asInstanceOf[ClassType] def scrutineeClassType: ClassType = scrutinee.getType.asInstanceOf[ClassType]
override def equals(that: Any): Boolean = (that != null) && (that match {
case t: MatchExpr => t.scrutinee == scrutinee && t.cases == cases
case _ => false
})
override def hashCode: Int = scrutinee.hashCode+cases.hashCode
} }
sealed abstract class MatchCase extends Serializable { sealed abstract class MatchCase extends Serializable {
...@@ -184,6 +191,13 @@ object Trees { ...@@ -184,6 +191,13 @@ object Trees {
class And private (val exprs: Seq[Expr]) extends Expr with FixedType { class And private (val exprs: Seq[Expr]) extends Expr with FixedType {
val fixedType = BooleanType val fixedType = BooleanType
override def equals(that: Any): Boolean = (that != null) && (that match {
case t: And => t.exprs == exprs
case _ => false
})
override def hashCode: Int = exprs.hashCode
} }
object Or { object Or {
...@@ -203,6 +217,13 @@ object Trees { ...@@ -203,6 +217,13 @@ object Trees {
class Or(val exprs: Seq[Expr]) extends Expr with FixedType { class Or(val exprs: Seq[Expr]) extends Expr with FixedType {
val fixedType = BooleanType val fixedType = BooleanType
override def equals(that: Any): Boolean = (that != null) && (that match {
case t: Or => t.exprs == exprs
case _ => false
})
override def hashCode: Int = exprs.hashCode
} }
object Iff { object Iff {
...@@ -221,6 +242,13 @@ object Trees { ...@@ -221,6 +242,13 @@ object Trees {
class Iff(val left: Expr, val right: Expr) extends Expr with FixedType { class Iff(val left: Expr, val right: Expr) extends Expr with FixedType {
val fixedType = BooleanType val fixedType = BooleanType
override def equals(that: Any): Boolean = (that != null) && (that match {
case t: Iff => t.left == left
case _ => false
})
override def hashCode: Int = left.hashCode + right.hashCode
} }
object Implies { object Implies {
...@@ -242,6 +270,13 @@ object Trees { ...@@ -242,6 +270,13 @@ object Trees {
// println("culprits: " + left.getType + ", " + right.getType) // println("culprits: " + left.getType + ", " + right.getType)
// assert(false) // assert(false)
// } // }
override def equals(that: Any): Boolean = (that != null) && (that match {
case t: Iff => t.left == left
case _ => false
})
override def hashCode: Int = left.hashCode + right.hashCode
} }
case class Not(expr: Expr) extends Expr with FixedType { case class Not(expr: Expr) extends Expr with FixedType {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment