summaryrefslogtreecommitdiff
path: root/st
diff options
context:
space:
mode:
Diffstat (limited to 'st')
-rw-r--r--st/ClassInstance.java6
-rw-r--r--st/SymbolTable.java4
2 files changed, 8 insertions, 2 deletions
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()));