diff options
-rw-r--r-- | output/negative/FailedOverride-error.java | 21 | ||||
-rw-r--r-- | st/SymbolTable.java | 2 |
2 files changed, 22 insertions, 1 deletions
diff --git a/output/negative/FailedOverride-error.java b/output/negative/FailedOverride-error.java new file mode 100644 index 0000000..9ffac74 --- /dev/null +++ b/output/negative/FailedOverride-error.java @@ -0,0 +1,21 @@ +class FailedOverrride { + public static void main(String[] args) { + System.out.println(new A().init()); + } +} + +class A { + public int init() { + return 0; + } + + public int x(A a) { + return 1; + } +} + +class B extends A { + public int x(B a) { + return 2; + } +} diff --git a/st/SymbolTable.java b/st/SymbolTable.java index 63832e6..0fca239 100644 --- a/st/SymbolTable.java +++ b/st/SymbolTable.java @@ -88,7 +88,7 @@ public class SymbolTable { m.getName(), cls.getName())); for (int i = 0; i < actual.size(); ++i) { - if (!expected.get(i).getClassInstance().equalsOnExtend(actual.get(i).getClassInstance())) { + if (!expected.get(i).getClassInstance().equals(actual.get(i).getClassInstance())) { throw new TypecheckException(String.format("SymbolTable found that %s is overwritten in %s!", m.getName(), cls.getName())); |