diff options
author | Martin Odersky <odersky@gmail.com> | 2003-08-27 13:30:34 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2003-08-27 13:30:34 +0000 |
commit | 03a8443eea6b6b6a780264ca7c09bb0354ac8e44 (patch) | |
tree | 1bc0af3dead4a1fd059825519297fff2d5ff4281 /sources/scalac/typechecker/RefCheck.java | |
parent | c6bfe08b2ee617f688b2e29572ca3b1caf7e97d0 (diff) | |
download | scala-03a8443eea6b6b6a780264ca7c09bb0354ac8e44.tar.gz scala-03a8443eea6b6b6a780264ca7c09bb0354ac8e44.tar.bz2 scala-03a8443eea6b6b6a780264ca7c09bb0354ac8e44.zip |
*** empty log message ***
Diffstat (limited to 'sources/scalac/typechecker/RefCheck.java')
-rw-r--r-- | sources/scalac/typechecker/RefCheck.java | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/sources/scalac/typechecker/RefCheck.java b/sources/scalac/typechecker/RefCheck.java index e78d628631..460e98abeb 100644 --- a/sources/scalac/typechecker/RefCheck.java +++ b/sources/scalac/typechecker/RefCheck.java @@ -9,6 +9,7 @@ package scalac.typechecker; import java.util.HashMap; +import java.util.Iterator; import scalac.*; import scalac.util.*; import scalac.ast.*; @@ -62,6 +63,7 @@ public class RefCheck extends Transformer implements Modifiers, Kinds { */ void checkAllOverrides(int pos, Symbol clazz) { Type[] closure = clazz.closure(); + HashMap/*<Symbol,Symbol>*/ overrides = null; for (int i = 0; i < closure.length; i++) { for (Scope.SymbolIterator it = closure[i].members().iterator(); it.hasNext();) { @@ -77,23 +79,25 @@ 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.flags & OVERRIDE) != 0) { + if (overrides == null) + overrides = new HashMap(); + if ((other.flags & DEFERRED) == 0 || + overrides.get(member) == null) + overrides.put(member, other); } - if ((other.flags & OVERRIDE) != 0) { - Type[] clparents = closure[i].parents(); - Symbol sym1 = null; - for (int j = clparents.length - 1; sym1 == null && j > 0; j--) - sym1 = clparents[j].lookup(other.name); - if (sym1 == null) { - Symbol superclazz = clazz.info().parents()[0].symbol(); - if (superclazz.isSubClass(closure[i].symbol())) - superclazz = clparents[0].symbol(); - sym1 = superclazz.lookup(other.name); - } - if (sym1 != null && (sym1.flags & DEFERRED) != 0) - abstractClassError( - clazz, other + other.locationString() + - " is marked `override' and overrides an abstract member" + sym1.locationString()); - } + } + } + } + if (overrides != null) { + 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"); } } } |