Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- case eq : Equals => {
- val primTypes : List[Type] = List(TString, TInt, TBoolean, TIntArr, TUnit)
- // We want to consider all types, so we need to append class types through anyObject
- val lhsType : Type = tcExpr(eq.lhs, (primTypes ::: List(anyObject)): _*)
- lhsType match {
- case TObject(classSymbol) => {
- tcExpr(eq.rhs, anyObject)
- TBoolean
- }
- case prim if primTypes.contains(prim) => {
- tcExpr(eq.rhs, prim)
- TBoolean
- }
- case _ => {
- val rhsType : Type = tcExpr(eq.rhs)
- fatal("Type error: Equality operator requires compatible types, but found types: "
- + lhsType + " and " + rhsType)
- TError
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement