diff options
author | Martin Odersky <odersky@gmail.com> | 2003-08-21 10:52:06 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2003-08-21 10:52:06 +0000 |
commit | 83f7f3a7580fd8d61b7a6ccda20114128fa6797e (patch) | |
tree | b25f4ec18ada5a04a1a0e93493fcf029240822e3 /sources | |
parent | d1d13f56f1989f367878553ab2853c5183f5360d (diff) | |
download | scala-83f7f3a7580fd8d61b7a6ccda20114128fa6797e.tar.gz scala-83f7f3a7580fd8d61b7a6ccda20114128fa6797e.tar.bz2 scala-83f7f3a7580fd8d61b7a6ccda20114128fa6797e.zip |
*** empty log message ***
Diffstat (limited to 'sources')
-rw-r--r-- | sources/scalac/ast/printer/TextTreePrinter.java | 2 | ||||
-rw-r--r-- | sources/scalac/symtab/Symbol.java | 32 |
2 files changed, 32 insertions, 2 deletions
diff --git a/sources/scalac/ast/printer/TextTreePrinter.java b/sources/scalac/ast/printer/TextTreePrinter.java index 07859f0215..50ff615b6d 100644 --- a/sources/scalac/ast/printer/TextTreePrinter.java +++ b/sources/scalac/ast/printer/TextTreePrinter.java @@ -613,7 +613,7 @@ public class TextTreePrinter implements TreePrinter { protected String symbolString(Symbol symbol, Name name) { if (symbol != null) - return symbol.name.toString(); + return symbol.simpleName().toString(); else return name.toString(); } diff --git a/sources/scalac/symtab/Symbol.java b/sources/scalac/symtab/Symbol.java index 99731aa056..bee27bf63a 100644 --- a/sources/scalac/symtab/Symbol.java +++ b/sources/scalac/symtab/Symbol.java @@ -984,7 +984,7 @@ public abstract class Symbol implements Modifiers, Kinds { //System.out.println(this + ":" + this.type() + locationString() + " overrides? " + sym1 + sym1.type() + sym1.locationString()); //DEBUG //System.out.println(owner.thisType());//DEBUG - Type symtype = owner.thisType().memberType(this); + Type symtype = this.type();//owner.thisType().memberType(this); //todo: try whether we can do: this.type(); instead Type sym1type = owner.thisType().memberType(sym1); switch (sym1type) { @@ -1003,6 +1003,36 @@ public abstract class Symbol implements Modifiers, Kinds { } } + /** The symbol which is overridden by this symbol in base class `base' + * `base' must be a superclass of this.owner(). + */ + public Symbol overridingSymbol(Type sub) { + assert !isOverloaded() : this; + Symbol sym1 = sub.lookupNonPrivate(name); + if (sym1.kind == Kinds.NONE || (sym1.flags & STATIC) != 0) { + return Symbol.NONE; + } else { + //System.out.println(this + ":" + this.type() + locationString() + " overrides? " + sym1 + sym1.type() + sym1.locationString()); //DEBUG + //System.out.println(owner.thisType());//DEBUG + + Type symtype = sub.memberType(this); + Type sym1type = sub.memberType(sym1); + switch (sym1type) { + case OverloadedType(Symbol[] alts, Type[] alttypes): + for (int i = 0; i < alts.length; i++) { + if (alttypes[i].isSubType(symtype)) return alts[i]; + } + return Symbol.NONE; + default: + if (sym1type.isSubType(symtype)) return sym1; + else { + if (Global.instance.debug) System.out.println(this + locationString() + " is not overridden by " + sym1 + sym1.locationString() + ", since " + sym1type + " !<= " + symtype);//DEBUG + return Symbol.NONE; + } + } + } + } + /** Does this symbol override that symbol? */ public boolean overrides(Symbol that) { |