diff options
author | Martin Odersky <odersky@gmail.com> | 2003-10-08 14:52:49 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2003-10-08 14:52:49 +0000 |
commit | 66077bf0c6211cbdc0109195c7a28be82b0f4261 (patch) | |
tree | df36968fa3ae4cffe09fcb6d90fa74a559f0fe25 /sources/scalac/typechecker/RefCheck.java | |
parent | 9d803bdc8a1001bcbe39bf836d837f07a320ec25 (diff) | |
download | scala-66077bf0c6211cbdc0109195c7a28be82b0f4261.tar.gz scala-66077bf0c6211cbdc0109195c7a28be82b0f4261.tar.bz2 scala-66077bf0c6211cbdc0109195c7a28be82b0f4261.zip |
*** empty log message ***
Diffstat (limited to 'sources/scalac/typechecker/RefCheck.java')
-rw-r--r-- | sources/scalac/typechecker/RefCheck.java | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/sources/scalac/typechecker/RefCheck.java b/sources/scalac/typechecker/RefCheck.java index 5178c3b703..799de7a290 100644 --- a/sources/scalac/typechecker/RefCheck.java +++ b/sources/scalac/typechecker/RefCheck.java @@ -64,11 +64,10 @@ public class RefCheck extends Transformer implements Modifiers, Kinds { */ void checkAllOverrides(int pos, Symbol clazz) { Type[] closure = clazz.closure(); - HashMap/*<Symbol,Symbol>*/ overrides = new HashMap(); for (int i = 0; i < closure.length; i++) { for (Scope.SymbolIterator it = closure[i].members().iterator(true); it.hasNext();) { - checkOverride(pos, clazz, it.next(), overrides); + checkOverride(pos, clazz, it.next()); } } @@ -83,24 +82,20 @@ public class RefCheck extends Transformer implements Modifiers, Kinds { if (i < 0) { unit.error(sym.pos, sym + " overrides nothing"); sym.flags &= ~OVERRIDE; + } else if (clazz.kind == CLASS && + (clazz.flags & ABSTRACTCLASS) == 0) { + Symbol sup = sym.overriddenSymbol(parents[0]); + if (sup.kind != NONE && (sup.flags & DEFERRED) != 0) { + abstractClassError( + clazz, sym + sym.locationString() + + " is marked `override', but overrides an abstract member of the superclass " + parents[0]); + } } } } - - for (Iterator/*<Symbol>*/ it = overrides.keySet().iterator(); - it.hasNext();) { - Symbol member = (Symbol) it.next(); - Symbol other = (Symbol) overrides.get(member); - if ((other.flags & DEFERRED) != 0) { - abstractClassError( - clazz, member + member.locationString() + - " is marked `override' and overrides only abstract members" + other + other.locationString()); - } - } } - void checkOverride(int pos, Symbol clazz, Symbol other, - HashMap/*<Symbol,Symbol>*/ overrides) { + void checkOverride(int pos, Symbol clazz, Symbol other) { Symbol member = other; if ((other.flags & PRIVATE) == 0) { Symbol member1 = clazz.info().lookup(other.name); @@ -146,11 +141,7 @@ public class RefCheck extends Transformer implements Modifiers, Kinds { member + member.locationString() + " is not defined" + (((member.flags & MUTABLE) == 0) ? "" : "\n(Note that variables need to be initialized to be defined)")); - } else if (member != other && - (member.flags & OVERRIDE) != 0 && - ((other.flags & DEFERRED) == 0 || - overrides.get(member) == null)) - overrides.put(member, other); + } } } //where |