diff options
-rw-r--r-- | heat/TypeBundle.java | 4 | ||||
-rw-r--r-- | st/ClassInstance.java | 6 | ||||
-rw-r--r-- | st/SymbolTable.java | 4 |
3 files changed, 10 insertions, 4 deletions
diff --git a/heat/TypeBundle.java b/heat/TypeBundle.java index 1867e0d..b484cc4 100644 --- a/heat/TypeBundle.java +++ b/heat/TypeBundle.java @@ -29,8 +29,8 @@ class TypeBundle { return (other instanceof TypeBundle) && (tb = (TypeBundle) other).type == this.type && (tb.instance == this.instance || - (tb.instance != null && tb.instance.getExtend() != null && - tb.instance.getExtend().equals(this.instance))); + (tb.instance != null && + tb.instance.equalsOnExtend(this.instance))); } public boolean isClass() { diff --git a/st/ClassInstance.java b/st/ClassInstance.java index a794f96..a7a4500 100644 --- a/st/ClassInstance.java +++ b/st/ClassInstance.java @@ -16,6 +16,12 @@ public class ClassInstance extends AbstractInstance { @Override public boolean equals(Object other) { ClassInstance o; + return (other instanceof ClassInstance && + ((o = (ClassInstance) other).getName() == this.getName())); + } + + public boolean equalsOnExtend(Object other) { + ClassInstance o; if (other instanceof ClassInstance) o = (ClassInstance) other; else diff --git a/st/SymbolTable.java b/st/SymbolTable.java index bd76a13..63832e6 100644 --- a/st/SymbolTable.java +++ b/st/SymbolTable.java @@ -83,12 +83,12 @@ public class SymbolTable { ArrayList<TypeInstance> expected = exist.getArguments(); ArrayList<TypeInstance> actual = m.getArguments(); if (expected.size() != actual.size() || - !exist.getReturn().equals(m.getReturn())) + !exist.getReturn().equalsOnExtend(m.getReturn())) throw new TypecheckException(String.format("SymbolTable found that %s is overwritten in %s!", m.getName(), cls.getName())); for (int i = 0; i < actual.size(); ++i) { - if (!expected.get(i).getClassInstance().equals(actual.get(i).getClassInstance())) { + if (!expected.get(i).getClassInstance().equalsOnExtend(actual.get(i).getClassInstance())) { throw new TypecheckException(String.format("SymbolTable found that %s is overwritten in %s!", m.getName(), cls.getName())); |