summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpaltherr <paltherr@epfl.ch>2004-03-04 00:14:00 +0000
committerpaltherr <paltherr@epfl.ch>2004-03-04 00:14:00 +0000
commit5ff59b4a7aa36c480dd2284544a2c14bd498301d (patch)
treeffbc953714ef0fd039aec75d69395ffea6a6f23e
parent67089f9e05c90c5ae484b614ee8c64cf0cb62052 (diff)
downloadscala-5ff59b4a7aa36c480dd2284544a2c14bd498301d.tar.gz
scala-5ff59b4a7aa36c480dd2284544a2c14bd498301d.tar.bz2
scala-5ff59b4a7aa36c480dd2284544a2c14bd498301d.zip
- Added Type.NoPrefix
- Replaced ThisType(NONE) by NoPrefix
-rw-r--r--sources/scala/tools/scalac/typechecker/Analyzer.scala6
-rw-r--r--sources/scala/tools/scalac/typechecker/Infer.scala2
-rw-r--r--sources/scalac/ast/TreeGen.java2
-rw-r--r--sources/scalac/symtab/EntryTags.java3
-rw-r--r--sources/scalac/symtab/Symbol.java4
-rw-r--r--sources/scalac/symtab/SymbolCloner.java1
-rw-r--r--sources/scalac/symtab/SymbolSubstTypeMap.java4
-rw-r--r--sources/scalac/symtab/SymbolTablePrinter.java5
-rw-r--r--sources/scalac/symtab/Type.java25
-rw-r--r--sources/scalac/symtab/classfile/Pickle.java7
-rw-r--r--sources/scalac/symtab/classfile/UnPickle.java11
-rw-r--r--sources/scalac/transformer/ExpandMixinsPhase.java3
-rw-r--r--sources/scalac/transformer/ExplicitOuterClassesPhase.java1
-rw-r--r--sources/scalac/transformer/LambdaLift.java2
-rw-r--r--sources/scalac/transformer/LambdaLiftPhase.java17
15 files changed, 64 insertions, 29 deletions
diff --git a/sources/scala/tools/scalac/typechecker/Analyzer.scala b/sources/scala/tools/scalac/typechecker/Analyzer.scala
index 377b86645c..d9eda1a1ce 100644
--- a/sources/scala/tools/scalac/typechecker/Analyzer.scala
+++ b/sources/scala/tools/scalac/typechecker/Analyzer.scala
@@ -498,9 +498,9 @@ class Analyzer(global: scalac_Global, descr: AnalyzerPhase) extends Transformer(
val checkNoEscapeMap = new Type$Map() {
override def apply(t: Type): Type = {
t.unalias() match {
- case Type$TypeRef(pre, sym, args) =>
- if (pre.isInstanceOf[Type$ThisType]) checkNoEscape(t, sym);
- case Type$SingleType(Type$ThisType(_), sym) =>
+ case Type$TypeRef(Type.NoPrefix, sym, args) =>
+ checkNoEscape(t, sym);
+ case Type$SingleType(Type.NoPrefix, sym) =>
checkNoEscape(t, sym);
case _ =>
}
diff --git a/sources/scala/tools/scalac/typechecker/Infer.scala b/sources/scala/tools/scalac/typechecker/Infer.scala
index 72c6888692..5edc10d53e 100644
--- a/sources/scala/tools/scalac/typechecker/Infer.scala
+++ b/sources/scala/tools/scalac/typechecker/Infer.scala
@@ -146,7 +146,7 @@ class Infer(global: scalac_Global, gen: TreeGen, make: TreeFactory) extends scal
/** Does given `tparam' occur with variance `v' in type?
*/
private def variance(tparam: Symbol, tp: Type): int = tp match {
- case Type.ErrorType | Type.AnyType | Type.NoType |
+ case Type.ErrorType | Type.AnyType | Type.NoType | Type.NoPrefix |
Type$ThisType(_) | Type$ConstantType(_, _) =>
VARIANCES
case Type$TypeRef(pre, sym, args) =>
diff --git a/sources/scalac/ast/TreeGen.java b/sources/scalac/ast/TreeGen.java
index c832aca543..9ee22a0a32 100644
--- a/sources/scalac/ast/TreeGen.java
+++ b/sources/scalac/ast/TreeGen.java
@@ -251,6 +251,8 @@ public class TreeGen implements Kinds, Modifiers, TypeTags {
*/
public Tree mkRef(int pos, Type stable, Symbol symbol) {
switch (stable) {
+ case NoPrefix:
+ return Ident(pos, symbol);
case ThisType(Symbol clasz):
if (clasz.isRoot() || clasz.isNone()) return Ident(pos, symbol);
if (clasz.isPackage()) return mkRef(pos, mkGlobalRef(pos, clasz.module()), symbol); // !!!
diff --git a/sources/scalac/symtab/EntryTags.java b/sources/scalac/symtab/EntryTags.java
index 04cdcdc704..edceade341 100644
--- a/sources/scalac/symtab/EntryTags.java
+++ b/sources/scalac/symtab/EntryTags.java
@@ -86,7 +86,8 @@ public interface EntryTags {
LITERALdouble = 32,
LITERALstring = 33,
LITERALnull = 34,
- LITERALzero = 35;
+ LITERALzero = 35,
+ NOpre = 36;
int firstSymTag = NONEsym, lastSymTag = VALsym;
int firstTypeTag = NOtpe, lastTypeTag = FLAGGEDtpe;
diff --git a/sources/scalac/symtab/Symbol.java b/sources/scalac/symtab/Symbol.java
index d622e2cadd..9d6bf4cf0a 100644
--- a/sources/scalac/symtab/Symbol.java
+++ b/sources/scalac/symtab/Symbol.java
@@ -1907,6 +1907,10 @@ public final class NoSymbol extends Symbol {
throw new ApplicationError();
}
+ public Type thisType() {
+ return Type.NoPrefix;
+ }
+
public void reset(Type completer) {
}
}
diff --git a/sources/scalac/symtab/SymbolCloner.java b/sources/scalac/symtab/SymbolCloner.java
index 4ccca73d33..6b1e445053 100644
--- a/sources/scalac/symtab/SymbolCloner.java
+++ b/sources/scalac/symtab/SymbolCloner.java
@@ -151,6 +151,7 @@ public class SymbolCloner {
switch (type) {
case ErrorType:
case NoType:
+ case NoPrefix:
return type;
case ThisType(Symbol symbol):
Symbol clone = (Symbol)clones.get(symbol);
diff --git a/sources/scalac/symtab/SymbolSubstTypeMap.java b/sources/scalac/symtab/SymbolSubstTypeMap.java
index 47316f1799..144181faac 100644
--- a/sources/scalac/symtab/SymbolSubstTypeMap.java
+++ b/sources/scalac/symtab/SymbolSubstTypeMap.java
@@ -151,7 +151,7 @@ public class SymbolSubstTypeMap extends Type.Map {
public Type apply(Type type) {
switch (type) {
- case TypeRef(ThisType(_), Symbol symbol, Type[] args):
+ case TypeRef(NoPrefix, Symbol symbol, Type[] args):
Object value = types.get(symbol);
if (value != null) return (Type)value;
value = symbols.get(symbol);
@@ -159,7 +159,7 @@ public class SymbolSubstTypeMap extends Type.Map {
Type prefix = ((Type.TypeRef)type).pre;
return Type.typeRef(apply(prefix), (Symbol)value, map(args));
- case SingleType(ThisType(_), Symbol symbol):
+ case SingleType(NoPrefix, Symbol symbol):
Object value = types.get(symbol);
if (value != null) return (Type)value;
value = symbols.get(symbol);
diff --git a/sources/scalac/symtab/SymbolTablePrinter.java b/sources/scalac/symtab/SymbolTablePrinter.java
index d9fb0ab745..5493eca380 100644
--- a/sources/scalac/symtab/SymbolTablePrinter.java
+++ b/sources/scalac/symtab/SymbolTablePrinter.java
@@ -440,6 +440,7 @@ public class SymbolTablePrinter {
public SymbolTablePrinter printType0(Type type) {
printCommonPart(type);
switch (type) {
+ case NoPrefix:
case ThisType(_):
case SingleType(_,_):
return print(".type");
@@ -496,8 +497,9 @@ public class SymbolTablePrinter {
return print("<any type>");
case NoType:
return print("<notype>");
+ case NoPrefix:
+ return print("<noprefix>");
case ThisType(Symbol sym):
- if (sym == Symbol.NONE) return print("<local>.this");
if ((sym.isAnonymousClass() || sym.isCompoundSym()) && !global.debug)
return print("this");
return printSymbolName(sym).print(".this");
@@ -572,6 +574,7 @@ public class SymbolTablePrinter {
public SymbolTablePrinter printPrefix0(Type prefix) {
printCommonPart(prefix);
switch (prefix) {
+ case NoPrefix:
case ThisType(_):
case SingleType(_,_):
return print(".");
diff --git a/sources/scalac/symtab/Type.java b/sources/scalac/symtab/Type.java
index 49d0dea540..559b462e64 100644
--- a/sources/scalac/symtab/Type.java
+++ b/sources/scalac/symtab/Type.java
@@ -25,10 +25,13 @@ public class Type implements Modifiers, Kinds, TypeTags, EntryTags {
public case ErrorType; // not used after analysis
public case AnyType; // not used after analysis
public case NoType;
+ public case NoPrefix;
/** C.this.type
*/
- public case ThisType(Symbol sym);
+ public case ThisType(Symbol sym) {
+ assert sym.isClassType(): Debug.show(sym);
+ }
/** pre.sym.type
* sym represents a valueS
@@ -134,7 +137,7 @@ public class Type implements Modifiers, Kinds, TypeTags, EntryTags {
/** An owner-less ThisType
*/
- public static Type localThisType = ThisType(Symbol.NONE);
+ public static Type localThisType = NoPrefix;
/** An empty Type array */
public static final Type[] EMPTY_ARRAY = new Type[0];
@@ -658,6 +661,7 @@ public class Type implements Modifiers, Kinds, TypeTags, EntryTags {
*/
public boolean isStable() {
switch (unalias()) {
+ case NoPrefix:
case ThisType(_):
case SingleType(_, _):
case ConstantType(_, _):
@@ -674,6 +678,7 @@ public class Type implements Modifiers, Kinds, TypeTags, EntryTags {
*/
public boolean isLegalPrefix() {
switch (unalias()) {
+ case NoPrefix:
case ThisType(_):
case SingleType(_, _):
return true;
@@ -993,6 +998,7 @@ public class Type implements Modifiers, Kinds, TypeTags, EntryTags {
case ErrorType:
case AnyType:
case NoType:
+ case NoPrefix:
case UnboxedType(_):
case TypeVar(_, _):
case ThisType(_):
@@ -1342,12 +1348,12 @@ public class Type implements Modifiers, Kinds, TypeTags, EntryTags {
public Type apply(Type t) {
switch (t) {
- case TypeRef(ThisType(_), Symbol sym, Type[] args):
+ case TypeRef(NoPrefix, Symbol sym, Type[] args):
for (int i = 0; i < from.length; i++) {
if (matches(sym, from[i])) return replacement(i, t);
}
break;
- case SingleType(ThisType(_), Symbol sym):
+ case SingleType(NoPrefix, Symbol sym):
for (int i = 0; i < from.length; i++) {
if (matches(sym, from[i])) return replacement(i, t);
}
@@ -1575,9 +1581,10 @@ public class Type implements Modifiers, Kinds, TypeTags, EntryTags {
private void initialize(Symbol clasz, Type type) {
switch (type) {
+ case NoPrefix:
+ return;
case ThisType(Symbol symbol):
if (symbol == clasz) return;
- if (symbol.isNone()) return; // !!!
}
subst.put(clasz, type);
Type base = type.baseType(clasz);
@@ -1839,6 +1846,7 @@ public class Type implements Modifiers, Kinds, TypeTags, EntryTags {
return true;
case NoType:
+ case NoPrefix:
return false;
case ThisType(_):
@@ -1944,6 +1952,7 @@ public class Type implements Modifiers, Kinds, TypeTags, EntryTags {
switch (this) {
case NoType:
+ case NoPrefix:
return false;
case ThisType(_):
case SingleType(_, _):
@@ -2218,6 +2227,7 @@ public class Type implements Modifiers, Kinds, TypeTags, EntryTags {
case AnyType:
return true;
case NoType:
+ case NoPrefix:
return false;
case TypeVar(Type origin, Constraint constr):
if (constr.inst != NoType) return constr.inst.isSameAs(this);
@@ -2226,6 +2236,7 @@ public class Type implements Modifiers, Kinds, TypeTags, EntryTags {
switch (this) {
case NoType:
+ case NoPrefix:
return false;
case TypeVar(Type origin, Constraint constr):
if (constr.inst != NoType) return constr.inst.isSameAs(that);
@@ -3129,6 +3140,8 @@ public class Type implements Modifiers, Kinds, TypeTags, EntryTags {
return ERROR;
case NoType:
return NOtpe;
+ case NoPrefix:
+ return NOpre;
case ThisType(Symbol sym):
return THIStpe
^ (sym.hashCode() * 41);
@@ -3195,6 +3208,8 @@ public class Type implements Modifiers, Kinds, TypeTags, EntryTags {
return that == ErrorType;
case NoType:
return that == NoType;
+ case NoPrefix:
+ return that == NoPrefix;
case ThisType(Symbol sym):
switch (that) {
case ThisType(Symbol sym1):
diff --git a/sources/scalac/symtab/classfile/Pickle.java b/sources/scalac/symtab/classfile/Pickle.java
index eb98a8d784..9a1f820385 100644
--- a/sources/scalac/symtab/classfile/Pickle.java
+++ b/sources/scalac/symtab/classfile/Pickle.java
@@ -163,6 +163,8 @@ public class Pickle implements Kinds, Modifiers, EntryTags {
switch (tp) {
case NoType:
break;
+ case NoPrefix:
+ break;
case ThisType(Symbol sym):
putSymbol(sym);
break;
@@ -378,7 +380,10 @@ public class Pickle implements Kinds, Modifiers, EntryTags {
writeByte(NOtpe);
writeByte(0); // space for length
break;
-
+ case NoPrefix:
+ writeByte(NOpre);
+ writeByte(0); // space for length
+ break;
case ThisType(Symbol sym):
writeByte(THIStpe);
writeByte(0); // space for length
diff --git a/sources/scalac/symtab/classfile/UnPickle.java b/sources/scalac/symtab/classfile/UnPickle.java
index 52831297e7..7efb9c318f 100644
--- a/sources/scalac/symtab/classfile/UnPickle.java
+++ b/sources/scalac/symtab/classfile/UnPickle.java
@@ -103,7 +103,7 @@ public class UnPickle implements Kinds, Modifiers, EntryTags, TypeTags {
boolean isTypeEntry(int i) {
int tag = bytes[index[i]];
- return (firstTypeTag <= tag && tag <= lastTypeTag);
+ return (firstTypeTag <= tag && tag <= lastTypeTag) || tag == NOpre;
}
boolean isSymbolEntry(int i) {
@@ -333,10 +333,15 @@ public class UnPickle implements Kinds, Modifiers, EntryTags, TypeTags {
case NOtpe:
tpe = Type.NoType;
break;
+ case NOpre:
+ tpe = Type.NoPrefix;
+ break;
case THIStpe:
Symbol sym = readSymbolRef();
- tpe = (sym.kind == NONE) ? Type.localThisType
- : Type.ThisType(sym);
+ tpe = (sym.kind == NONE) ? Type.NoPrefix : Type.ThisType(sym);
+ // !!! code above is usefull for the transition
+ // !!! after some time, replace it by the following line:
+ // !!! tpe = Type.ThisType(readSymbolRef());
break;
case SINGLEtpe:
Type prefix = readTypeRef();
diff --git a/sources/scalac/transformer/ExpandMixinsPhase.java b/sources/scalac/transformer/ExpandMixinsPhase.java
index 4635fc1b0f..68796b5996 100644
--- a/sources/scalac/transformer/ExpandMixinsPhase.java
+++ b/sources/scalac/transformer/ExpandMixinsPhase.java
@@ -424,8 +424,7 @@ public class ExpandMixinsPhase extends Phase {
Symbol clone = (Symbol)cloner.clones.get(symbol);
prefix = apply(prefix);
return Type.singleType(prefix, clone != null ? clone : symbol);
- case ThisType(Symbol symbol):
- if (symbol.isNone()) return type;
+ case ThisType(_):
return clasz.thisType();
case CompoundType(Type[] parents, Scope members):
if (type.symbol() != clasz) return map(type);
diff --git a/sources/scalac/transformer/ExplicitOuterClassesPhase.java b/sources/scalac/transformer/ExplicitOuterClassesPhase.java
index 06c6cba348..e23807983c 100644
--- a/sources/scalac/transformer/ExplicitOuterClassesPhase.java
+++ b/sources/scalac/transformer/ExplicitOuterClassesPhase.java
@@ -318,7 +318,6 @@ public class ExplicitOuterClassesPhase extends Phase {
case SingleType(Type prefix, Symbol symbol):
return Type.singleType(apply(prefix), symbol);
case ThisType(Symbol clasz):
- if (clasz.isNone()) return type;
if (clasz == context.clasz) return type;
for (int i = 0; i < context.outers.length; i++)
if (clasz == context.outers[i].clasz)
diff --git a/sources/scalac/transformer/LambdaLift.java b/sources/scalac/transformer/LambdaLift.java
index 4cf2eb0e44..f70a8479ba 100644
--- a/sources/scalac/transformer/LambdaLift.java
+++ b/sources/scalac/transformer/LambdaLift.java
@@ -203,7 +203,7 @@ public class LambdaLift extends OwnerTransformer
public Type apply(Type tp) {
if (global.debug) global.log("traverse " + tp);//debug
switch (tp) {
- case TypeRef(ThisType(_), Symbol sym, Type[] targs):
+ case TypeRef(NoPrefix, Symbol sym, Type[] targs):
if (isLocal(sym, currentOwner) &&
sym.kind == TYPE &&
!excluded.contains(sym))
diff --git a/sources/scalac/transformer/LambdaLiftPhase.java b/sources/scalac/transformer/LambdaLiftPhase.java
index 4e90986eb1..a60285dd99 100644
--- a/sources/scalac/transformer/LambdaLiftPhase.java
+++ b/sources/scalac/transformer/LambdaLiftPhase.java
@@ -70,14 +70,18 @@ public class LambdaLiftPhase extends Phase implements Kinds, Modifiers {
case TypeRef(Type pre, Symbol sym, Type[] targs):
if (sym.kind == CLASS) {
switch (pre) {
- case ThisType(Symbol s):
- if (s == Symbol.NONE) {
- pre = sym.owner().enclClass().thisType();
- tp = Type.typeRef(pre, sym, targs);
- }
+ case NoPrefix:
+ pre = sym.owner().enclClass().thisType();
+ tp = Type.typeRef(pre, sym, targs);
}
}
switch (pre) {
+ case NoPrefix:
+ if (LambdaLift.isLocal(sym, owner)) {
+ assert targs.length == 0;
+ return proxy(sym, owner).type();
+ }
+ break;
case ThisType(_):
if (sym.kind == CLASS &&
sym.primaryConstructor().isUpdatedAt(LambdaLiftPhase.this)) {
@@ -97,9 +101,6 @@ public class LambdaLiftPhase extends Phase implements Kinds, Modifiers {
}
return Type.typeRef(pre, sym, targs1);
}
- } else if (LambdaLift.isLocal(sym, owner)) {
- assert targs.length == 0;
- return proxy(sym, owner).type();
}
}
break;