diff options
author | paltherr <paltherr@epfl.ch> | 2004-01-23 20:12:48 +0000 |
---|---|---|
committer | paltherr <paltherr@epfl.ch> | 2004-01-23 20:12:48 +0000 |
commit | 7a9f373473233a4ba69945e5cf4cb6527eac9584 (patch) | |
tree | 88e41ab9da28d769281a28ffc14db67bee51479d /sources/scalac/symtab/Symbol.java | |
parent | 05b798c3d173e77e6cce19f1a894f55708d7eb2f (diff) | |
download | scala-7a9f373473233a4ba69945e5cf4cb6527eac9584.tar.gz scala-7a9f373473233a4ba69945e5cf4cb6527eac9584.tar.bz2 scala-7a9f373473233a4ba69945e5cf4cb6527eac9584.zip |
- Added method Symbol.rebindSym and field Class...
- Added method Symbol.rebindSym and field ClassSymbol.rebindSym
Diffstat (limited to 'sources/scalac/symtab/Symbol.java')
-rw-r--r-- | sources/scalac/symtab/Symbol.java | 45 |
1 files changed, 41 insertions, 4 deletions
diff --git a/sources/scalac/symtab/Symbol.java b/sources/scalac/symtab/Symbol.java index c3ab4a6503..47fb4588b1 100644 --- a/sources/scalac/symtab/Symbol.java +++ b/sources/scalac/symtab/Symbol.java @@ -1285,12 +1285,20 @@ public abstract class Symbol implements Modifiers, Kinds { this.setInfo(completer); } + /** + * Returns the symbol to use in case of a rebinding due to a more + * precise type prefix. + */ + public Symbol rebindSym() { + return this; + } + /** return a tag which (in the ideal case) uniquely identifies * class symbols */ - public int tag() { - return name.toString().hashCode(); - } + public int tag() { + return name.toString().hashCode(); + } } /** A class for term symbols @@ -1510,7 +1518,9 @@ public abstract class TypeSymbol extends Symbol { result = fixConstrType(result, clone); return new Type.PolyType(tparams, result); case TypeRef(Type pre, Symbol sym, Type[] args): - assert sym == this : Debug.show(sym) + " != " + Debug.show(this); + if (sym != this && isTypeAlias() && owner().isCompoundSym()) + return type; + assert sym == this: Debug.show(sym) + " != " + Debug.show(this); return new Type.TypeRef(pre, clone, args); case LazyType(): return type; @@ -1773,11 +1783,34 @@ public class ClassSymbol extends TypeSymbol { */ final private Type thistp = Type.ThisType(this); + private final Symbol rebindSym; + /** Principal Constructor */ public ClassSymbol(int pos, Name name, Symbol owner, int flags) { super(CLASS, pos, name, owner, flags); this.mangled = name; + this.rebindSym = new AliasTypeSymbol(pos, Names.ALIAS(this), owner, 0); + Type rebindType = new ClassAliasLazyType(); + this.rebindSym.setInfo(rebindType); + this.rebindSym.primaryConstructor().setInfo(rebindType); + } + + private class ClassAliasLazyType extends Type.LazyType { + public void complete(Symbol ignored) { + Symbol clasz = ClassSymbol.this; + Symbol alias = rebindSym; + Type prefix = clasz.owner().thisType(); + Type constrtype = Type.TypeRef(prefix, alias,Type.EMPTY_ARRAY); + constrtype = Type.MethodType(Symbol.EMPTY_ARRAY, constrtype); + constrtype = Type.PolyType(clasz.typeParams(), constrtype); + constrtype = constrtype.cloneType( + clasz.primaryConstructor(), alias.primaryConstructor()); + alias.primaryConstructor().setInfo(constrtype); + Symbol[] tparams = constrtype.typeParams(); + Type info = Type.TypeRef(prefix, clasz, Symbol.type(tparams)); + alias.setInfo(info); + } } public static ClassSymbol define( @@ -1914,6 +1947,10 @@ public class ClassSymbol extends TypeSymbol { return sym; } + public final Symbol rebindSym() { + return rebindSym; + } + public void reset(Type completer) { super.reset(completer); module().reset(completer); |