summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpaltherr <paltherr@epfl.ch>2004-01-07 16:28:24 +0000
committerpaltherr <paltherr@epfl.ch>2004-01-07 16:28:24 +0000
commitb05601a61b5ff8783cac2a47ae7ed3fe3430055b (patch)
treeb675d0b95670b9d3d9498703429b0ceb3d9e8191
parent836f5fbd907fe00bd9bd3849f1d41b13c2afd53a (diff)
downloadscala-b05601a61b5ff8783cac2a47ae7ed3fe3430055b.tar.gz
scala-b05601a61b5ff8783cac2a47ae7ed3fe3430055b.tar.bz2
scala-b05601a61b5ff8783cac2a47ae7ed3fe3430055b.zip
- Added correct owner to non-class compound types
-rw-r--r--sources/scala/tools/scalac/typechecker/Analyzer.scala10
-rw-r--r--sources/scalac/symtab/Type.java10
-rw-r--r--sources/scalac/symtab/classfile/Pickle.java6
-rw-r--r--sources/scalac/symtab/classfile/UnPickle.java8
-rw-r--r--sources/scalac/typechecker/Analyzer.java10
5 files changed, 19 insertions, 25 deletions
diff --git a/sources/scala/tools/scalac/typechecker/Analyzer.scala b/sources/scala/tools/scalac/typechecker/Analyzer.scala
index a51b395ecc..bfc9082add 100644
--- a/sources/scala/tools/scalac/typechecker/Analyzer.scala
+++ b/sources/scala/tools/scalac/typechecker/Analyzer.scala
@@ -1197,11 +1197,11 @@ class Analyzer(global: scalac_Global, descr: AnalyzerPhase) extends Transformer(
val parts1 = new Array[Type](parts.length + 1);
System.arraycopy(parts, 0, parts1, 0, parts.length);
parts1(parts.length) = clazz.getType();
- Type.compoundType(parts1, members);
+ Type.compoundTypeWithOwner(clazz.owner().enclClass(), parts1, members);
case _ =>
- Type.compoundType(
- NewArray.Type(selftype, clazz.getType()), Scope.EMPTY);
+ Type.compoundTypeWithOwner(
+ clazz.owner().enclClass(), NewArray.Type(selftype, clazz.getType()), Scope.EMPTY);
}
sym.setInfo(selftype1);
@@ -2278,7 +2278,7 @@ class Analyzer(global: scalac_Global, descr: AnalyzerPhase) extends Transformer(
// compute template's type with new refinement scope.
val parentTypes = clazz.info().parents();
val refinement: Scope = new Scope();
- val base: Type = Type.compoundType(parentTypes, Scope.EMPTY);
+ val base: Type = Type.compoundTypeWithOwner(context.enclClass.owner, parentTypes, Scope.EMPTY);
/*
val it: Scope$SymbolIterator = clazz.members().iterator();
while (it.hasNext()) {
@@ -2735,7 +2735,7 @@ class Analyzer(global: scalac_Global, descr: AnalyzerPhase) extends Transformer(
val parents1 = transform(parents, TYPEmode);
val ptypes = Tree.typeOf(parents);
val members: Scope = new Scope();
- val self: Type = Type.compoundType(ptypes, members);
+ val self: Type = Type.compoundTypeWithOwner(context.enclClass.owner, ptypes, members);
val clazz: Symbol = self.symbol();
pushContext(tree, clazz, members);
var i = 0; while (i < refinements.length) {
diff --git a/sources/scalac/symtab/Type.java b/sources/scalac/symtab/Type.java
index e8ed6058a3..b47ec08ab9 100644
--- a/sources/scalac/symtab/Type.java
+++ b/sources/scalac/symtab/Type.java
@@ -213,10 +213,10 @@ public class Type implements Modifiers, Kinds, TypeTags, EntryTags {
return res;
}
- public static CompoundType compoundType(Type[] parts, Scope members) {
+ public static CompoundType compoundTypeWithOwner(Symbol owner, Type[] parts, Scope members) {
ExtCompoundType res = new ExtCompoundType(parts, members);
res.tsym = new ClassSymbol(
- Position.FIRSTPOS, Names.COMPOUND_NAME.toTypeName(), Symbol.NONE,
+ Position.FIRSTPOS, Names.COMPOUND_NAME.toTypeName(), owner,
SYNTHETIC | ABSTRACT);
res.tsym.setInfo(res);
res.tsym.primaryConstructor().setInfo(
@@ -1039,7 +1039,7 @@ public class Type implements Modifiers, Kinds, TypeTags, EntryTags {
} else {
Scope members2 = new Scope();
//Type tp1 = compoundType(parts1, members2);
- Type tp1 = (tp.symbol().isCompoundSym()) ? compoundType(parts1, members2)
+ Type tp1 = (tp.symbol().isCompoundSym()) ? compoundTypeWithOwner(tp.symbol().owner(), parts1, members2)
: compoundType(parts1, members2, tp.symbol());
Symbol[] syms1 = members1.elements();
Symbol[] syms2 = new Symbol[syms1.length];
@@ -2578,7 +2578,7 @@ public class Type implements Modifiers, Kinds, TypeTags, EntryTags {
// add refinements where necessary
Scope members = new Scope();
- Type lubType = compoundType(leastBaseTypes, members);
+ Type lubType = compoundTypeWithOwner(Symbol.NONE, leastBaseTypes, members); // !!! NONE
/*
Type lubThisType = lubType.narrow();
//System.out.println("lubtype = " + lubType);//DEBUG
@@ -2751,7 +2751,7 @@ public class Type implements Modifiers, Kinds, TypeTags, EntryTags {
}
}
- CompoundType glbType = compoundType(Type.EMPTY_ARRAY, new Scope());
+ CompoundType glbType = compoundTypeWithOwner(Symbol.NONE, Type.EMPTY_ARRAY, new Scope()); // !!! NONE
Type glbThisType = glbType.narrow();
// step 3: compute glb of all refinements.
diff --git a/sources/scalac/symtab/classfile/Pickle.java b/sources/scalac/symtab/classfile/Pickle.java
index 3a3747822b..7309f4d8d7 100644
--- a/sources/scalac/symtab/classfile/Pickle.java
+++ b/sources/scalac/symtab/classfile/Pickle.java
@@ -179,8 +179,7 @@ public class Pickle implements Kinds, Modifiers, EntryTags {
putTypes(args);
break;
case CompoundType(Type[] parents, Scope members):
- if (!tp.symbol().isCompoundSym())
- putSymbol(tp.symbol());
+ putSymbol(tp.symbol());
putTypes(parents);
break;
case MethodType(Symbol[] vparams, Type result):
@@ -409,8 +408,7 @@ public class Pickle implements Kinds, Modifiers, EntryTags {
case CompoundType(Type[] parents, Scope members):
writeByte(COMPOUNDtpe);
writeByte(0); // space for length
- if (!tp.symbol().isCompoundSym())
- writeRef(tp.symbol());
+ writeRef(tp.symbol());
writeRefs(parents);
break;
diff --git a/sources/scalac/symtab/classfile/UnPickle.java b/sources/scalac/symtab/classfile/UnPickle.java
index 905e5a8b22..028c5a1ecd 100644
--- a/sources/scalac/symtab/classfile/UnPickle.java
+++ b/sources/scalac/symtab/classfile/UnPickle.java
@@ -347,13 +347,9 @@ public class UnPickle implements Kinds, Modifiers, EntryTags, TypeTags {
break;
case COMPOUNDtpe:
Symbol[] clazzs = readSymbolRefs(end);
+ assert clazzs.length == 1;
Type[] parents = readTypeRefs(end);
- if (clazzs.length == 0) {
- tpe = Type.compoundType(parents, new Scope());
- } else {
- assert clazzs.length == 1;
- tpe = Type.compoundType(parents, new Scope(), clazzs[0]);
- }
+ tpe = Type.compoundType(parents, new Scope(), clazzs[0]);
break;
case METHODtpe:
Type restype = readTypeRef();
diff --git a/sources/scalac/typechecker/Analyzer.java b/sources/scalac/typechecker/Analyzer.java
index 8f7cece248..84c9c6b4a4 100644
--- a/sources/scalac/typechecker/Analyzer.java
+++ b/sources/scalac/typechecker/Analyzer.java
@@ -1192,12 +1192,12 @@ public class Analyzer extends Transformer implements Modifiers, Kinds {
Type[] parts1 = new Type[parts.length + 1];
System.arraycopy(parts, 0, parts1, 0, parts.length);
parts1[parts.length] = clazz.type();
- sym.setInfo(Type.compoundType(parts1, members));
+ sym.setInfo(Type.compoundTypeWithOwner(clazz.owner().enclClass(), parts1, members));
break;
default:
sym.setInfo(
- Type.compoundType(
- new Type[]{selftype, clazz.type()}, Scope.EMPTY));
+ Type.compoundTypeWithOwner(
+ clazz.owner().enclClass(), new Type[]{selftype, clazz.type()}, Scope.EMPTY));
}
this.unit = savedUnit;
@@ -2184,7 +2184,7 @@ public class Analyzer extends Transformer implements Modifiers, Kinds {
// compute template's type with new refinement scope.
Type[] parentTypes = clazz.info().parents();
Scope refinement = new Scope();
- Type base = Type.compoundType(parentTypes, Scope.EMPTY);
+ Type base = Type.compoundTypeWithOwner(context.enclClass.owner, parentTypes, Scope.EMPTY);
Type owntype = Type.compoundType(
parentTypes, refinement, clazz);
Scope.SymbolIterator it = clazz.members().iterator();
@@ -2625,7 +2625,7 @@ public class Analyzer extends Transformer implements Modifiers, Kinds {
Tree[] parents1 = transform(parents, TYPEmode);
Type[] ptypes = Tree.typeOf(parents);
Scope members = new Scope();
- Type self = Type.compoundType(ptypes, members);
+ Type self = Type.compoundTypeWithOwner(context.enclClass.owner, ptypes, members);
Symbol clazz = self.symbol();
pushContext(tree, clazz, members);
for (int i = 0; i < refinements.length; i++) {