From 57a845d6766e58396184af3897915db42dfb6f6f Mon Sep 17 00:00:00 2001 From: paltherr Date: Thu, 2 Oct 2003 11:03:51 +0000 Subject: - Added a constructor to AbsTypeSymbols - Changed ExplicitOuter to replace all TypeRefs prefixes by - localThisTypes. Adapted ExpandMixins and Type to the new TypeRefs --- sources/scalac/symtab/Symbol.java | 21 +++++++++------------ sources/scalac/symtab/Type.java | 16 ++++++++++------ sources/scalac/transformer/ExpandMixins.java | 7 ++++--- .../transformer/ExplicitOuterClassesPhase.java | 22 ++++++++++++---------- 4 files changed, 35 insertions(+), 31 deletions(-) (limited to 'sources') diff --git a/sources/scalac/symtab/Symbol.java b/sources/scalac/symtab/Symbol.java index cc070c24af..6fa6a0db04 100644 --- a/sources/scalac/symtab/Symbol.java +++ b/sources/scalac/symtab/Symbol.java @@ -1358,8 +1358,7 @@ public abstract class TypeSymbol extends Symbol { public TypeSymbol(int kind, int pos, Name name, Symbol owner, int flags) { super(kind, pos, name, owner, flags); assert name.isTypeName() : this; - if (kind != TYPE) - this.constructor = TermSymbol.newConstructor(this, flags & ~MODUL); + this.constructor = TermSymbol.newConstructor(this, flags & ~MODUL); } protected void update(int pos, int flags) { @@ -1371,12 +1370,10 @@ public abstract class TypeSymbol extends Symbol { */ public void copyTo(Symbol sym) { super.copyTo(sym); - if (kind != TYPE) { - Symbol symconstr = ((TypeSymbol) sym).constructor; - constructor.copyTo(symconstr); - if (constructor.isInitialized()) - symconstr.setInfo(fixConstrType(symconstr.type(), sym)); - } + Symbol symconstr = ((TypeSymbol) sym).constructor; + constructor.copyTo(symconstr); + if (constructor.isInitialized()) + symconstr.setInfo(fixConstrType(symconstr.type(), sym)); } protected void copyConstructorInfo(TypeSymbol other) { @@ -1423,18 +1420,17 @@ public abstract class TypeSymbol extends Symbol { /** Get primary constructor */ public Symbol primaryConstructor() { - return (kind == TYPE) ? Symbol.NONE : constructor.firstAlternative(); + return constructor.firstAlternative(); } /** Get all constructors */ public Symbol allConstructors() { - return (kind == TYPE) ? Symbol.NONE : constructor; + return constructor; } /** Get type parameters */ public Symbol[] typeParams() { - return (kind == TYPE) ? Symbol.EMPTY_ARRAY - : primaryConstructor().info().typeParams(); + return primaryConstructor().info().typeParams(); } /** Get value parameters */ @@ -1611,6 +1607,7 @@ public class AbsTypeSymbol extends TypeSymbol { /** Constructor */ public AbsTypeSymbol(int pos, Name name, Symbol owner, int flags) { super(TYPE, pos, name, owner, flags); + allConstructors().setType(Type.MethodType(EMPTY_ARRAY, thisType())); } public static AbsTypeSymbol define( diff --git a/sources/scalac/symtab/Type.java b/sources/scalac/symtab/Type.java index bb4a63f7ce..8be3dcd00a 100644 --- a/sources/scalac/symtab/Type.java +++ b/sources/scalac/symtab/Type.java @@ -1011,11 +1011,14 @@ public class Type implements Modifiers, Kinds, TypeTags, EntryTags { */ static class AsSeenFromMap extends Map { - private Type pre; - private Symbol clazz; + private final Type pre; + private final Symbol clazz; + private final boolean local; AsSeenFromMap(Type pre, Symbol clazz) { this.pre = pre; this.clazz = clazz; + Global global = Global.instance; + this.local =global.PHASE.EXPLICITOUTER.id() 0) // !!! - if (owner.isClass() || owner.isConstructor()) + if (owner.isType() || owner.isConstructor()) type = getOuterTypeSubst(owner, true).apply(type); } @@ -121,9 +123,9 @@ public class ExplicitOuterClassesPhase extends Phase { //######################################################################## // Private Methods - Outer class - /** Returns the outer class of the given class or constructor. */ + /** Returns the outer class of the given type or constructor. */ private Symbol getOuterClass(Symbol symbol) { - assert symbol.isClass() || symbol.isConstructor(): Debug.show(symbol); + assert symbol.isType() || symbol.isConstructor(): Debug.show(symbol); return symbol.owner(); } @@ -140,12 +142,12 @@ public class ExplicitOuterClassesPhase extends Phase { return nextValueParams(symbol)[0]; } - /** Has the given class or constructor outer type links? */ + /** Has the given type or constructor outer type links? */ private boolean hasOuterTypeLinks(Symbol symbol) { - assert symbol.isClass() || symbol.isConstructor(): Debug.show(symbol); + assert symbol.isType() || symbol.isConstructor(): Debug.show(symbol); if (symbol.isJava()) return false; Symbol outer = getOuterClass(symbol); - return outer.isClass() && nextTypeParams(outer).length != 0; + return outer.isType() && nextTypeParams(outer).length != 0; } /** Returns the type substitution for the given class or constructor. */ @@ -212,11 +214,11 @@ public class ExplicitOuterClassesPhase extends Phase { public Type apply(Type type) { switch (type) { case TypeRef(Type prefix, Symbol symbol, Type[] targs): - if (!symbol.isClass()) break; + if (!symbol.owner().isType()) break; prefix = apply(prefix); targs = map(targs); targs = Type.concat(getOuterTypeArgs(prefix, symbol), targs); - return Type.TypeRef(prefix, symbol, targs); + return Type.TypeRef(Type.localThisType, symbol, targs); } return map(type); } -- cgit v1.2.3