diff options
Diffstat (limited to 'sources')
-rw-r--r-- | sources/scalac/ast/TreeGen.java | 3 | ||||
-rw-r--r-- | sources/scalac/symtab/Scope.java | 2 | ||||
-rw-r--r-- | sources/scalac/symtab/Symbol.java | 13 | ||||
-rw-r--r-- | sources/scalac/transformer/Erasure.java | 1 |
4 files changed, 16 insertions, 3 deletions
diff --git a/sources/scalac/ast/TreeGen.java b/sources/scalac/ast/TreeGen.java index 6a6c4903d5..c118b22899 100644 --- a/sources/scalac/ast/TreeGen.java +++ b/sources/scalac/ast/TreeGen.java @@ -638,7 +638,8 @@ public class TreeGen implements Kinds, Modifiers { clazz.info().members().enter(meth); changeOwner(visitor, prevOwner, meth); Tree body = Apply( - Select(Ident(param), definitions.MATCH), new Tree[]{visitor}); + Select(Ident(param), definitions.MATCH), new Tree[]{visitor}) + .setType(restype); return DefDef(meth, body); } diff --git a/sources/scalac/symtab/Scope.java b/sources/scalac/symtab/Scope.java index 6c707f43c4..64e06b61e6 100644 --- a/sources/scalac/symtab/Scope.java +++ b/sources/scalac/symtab/Scope.java @@ -183,7 +183,7 @@ public class Scope { public Scope enterOrOverload(Symbol sym) { Entry e = lookupEntry(sym.name); - if (e.owner == this && (sym.flags & Modifiers.PRIVATE) == 0) { + if (e.owner == this/* && (sym.flags & Modifiers.PRIVATE) == 0*/) { e.setSymbol(e.sym.overloadWith(sym)); return this; } else { diff --git a/sources/scalac/symtab/Symbol.java b/sources/scalac/symtab/Symbol.java index 57e85283a4..f69506fc6d 100644 --- a/sources/scalac/symtab/Symbol.java +++ b/sources/scalac/symtab/Symbol.java @@ -871,6 +871,7 @@ public abstract class Symbol implements Modifiers, Kinds { * `base' must be a superclass of this.owner(). */ public Symbol overriddenSymbol(Type base) { + assert !isOverloaded() : this; Symbol sym1 = base.lookupNonPrivate(name); if (sym1.kind == Kinds.NONE || (sym1.flags & STATIC) != 0) { return Symbol.NONE; @@ -884,7 +885,7 @@ public abstract class Symbol implements Modifiers, Kinds { switch (sym1type) { case OverloadedType(Symbol[] alts, Type[] alttypes): for (int i = 0; i < alts.length; i++) { - if (symtype.isSameAs(alttypes[i])) return alts[i]; + if (symtype.isSubType(alttypes[i])) return alts[i]; } return Symbol.NONE; default: @@ -897,6 +898,16 @@ public abstract class Symbol implements Modifiers, Kinds { } } + /** Does this symbol override that symbol? + */ + public boolean overrides(Symbol that) { + return + ((this.flags | that.flags) & (PRIVATE | STATIC)) == 0 && + this.name == that.name && + owner.thisType().memberType(this).isSubType( + owner.thisType().memberType(that)); + } + public void reset(Type completer) { this.flags &= (FINAL | MODUL); this.pos = 0; diff --git a/sources/scalac/transformer/Erasure.java b/sources/scalac/transformer/Erasure.java index ac7b0d401f..73ac09c2ac 100644 --- a/sources/scalac/transformer/Erasure.java +++ b/sources/scalac/transformer/Erasure.java @@ -251,6 +251,7 @@ public class Erasure extends Transformer implements Modifiers { bridgeSyms.put(sym, bridgesOfSym); // check that there is no overloaded symbol with same erasure as bridge + // todo: why only check for overloaded? Symbol overSym = sym.owner().members().lookup(sym.name); switch (overSym.type()) { case OverloadedType(Symbol[] alts, Type[] alttypes): |