summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2008-07-21 18:03:27 +0000
committerMartin Odersky <odersky@gmail.com>2008-07-21 18:03:27 +0000
commit1157b4042ddc3f928d82e7722b1619e628973a9c (patch)
treef7937b4714d3bd0980030f9d2f0d388b4f919985 /src
parentb894f804ad22bc1c16610785f34b62efcea4a514 (diff)
downloadscala-1157b4042ddc3f928d82e7722b1619e628973a9c.tar.gz
scala-1157b4042ddc3f928d82e7722b1619e628973a9c.tar.bz2
scala-1157b4042ddc3f928d82e7722b1619e628973a9c.zip
fixed build problem
Diffstat (limited to 'src')
-rwxr-xr-xsrc/compiler/scala/tools/nsc/symtab/BaseTypeSeqs.scala42
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Types.scala8
2 files changed, 38 insertions, 12 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/BaseTypeSeqs.scala b/src/compiler/scala/tools/nsc/symtab/BaseTypeSeqs.scala
index 1b8ddb192e..9947aa5209 100755
--- a/src/compiler/scala/tools/nsc/symtab/BaseTypeSeqs.scala
+++ b/src/compiler/scala/tools/nsc/symtab/BaseTypeSeqs.scala
@@ -62,6 +62,27 @@ trait BaseTypeSeqs {
def exists(p: Type => Boolean): Boolean = elems exists p
// (0 until length) exists (i => p(this(i)))
+ def normalize(parents: List[Type]) {
+ var j = 0
+ while (j < elems.length) {
+ elems(j) match {
+ case RefinedType(variants, decls) =>
+ // can't assert decls.isEmpty; see t0764
+ //if (!decls.isEmpty) assert(false, "computing closure of "+this+":"+this.isInstanceOf[RefinedType]+"/"+closureCache(j))
+ //Console.println("compute closure of "+this+" => glb("+variants+")")
+ elems(j) = mergePrefixAndArgs(variants, -1, maxBaseTypeSeqDepth(variants) + LubGlbMargin) match {
+ case Some(tp0) => tp0
+ case None => throw new TypeError(
+ "the type intersection "+(parents mkString " with ")+" is malformed"+
+ "\n --- because ---"+
+ "\n no common type instance of base types "+(variants mkString ", and ")+" exists.")
+ }
+ case _ =>
+ }
+ j += 1
+ }
+ }
+
lazy val maxDepth: Int = {
var d = 0
for (i <- 0 until length) d = Math.max(d, self.maxDepth(this(i)))
@@ -80,17 +101,17 @@ trait BaseTypeSeqs {
def baseTypeSingletonSeq(tp: Type): BaseTypeSeq = new BaseTypeSeq(Array(tp))
/** Create the base type sequence of a compound type wuth given tp.parents */
- def compoundBaseTypeSeq(tp: CompoundType): BaseTypeSeq = {
- //Console.println("computing baseTypeSeq of " + tsym.tpe + " " + tp.parents)//DEBUG
+ def compoundBaseTypeSeq(tsym: Symbol, parents: List[Type]): BaseTypeSeq = {
+// Console.println("computing baseTypeSeq of " + tsym.tpe + " " + parents)//DEBUG
val buf = new ListBuffer[Type]
- buf += tp.typeSymbol.tpe
+ buf += tsym.tpe
var btsSize = 1
- val nparents = tp.parents.length
+ val nparents = parents.length
if (nparents != 0) {
val pbtss = new Array[BaseTypeSeq](nparents)
val index = new Array[Int](nparents)
var i = 0
- for (p <- tp.parents) {
+ for (p <- parents) {
pbtss(i) =
if (p.baseTypeSeq eq undetBaseTypeSeq) AnyClass.info.baseTypeSeq
else p.baseTypeSeq
@@ -127,8 +148,10 @@ trait BaseTypeSeqs {
}
val elems = new Array[Type](btsSize)
buf.copyToArray(elems, 0)
- //Console.println("baseTypeSeqCache of " + tsym.tpe + " = " + arr.toString)//DEBUG
- tp.baseTypeSeqCache = new BaseTypeSeq(elems)
+// Console.println("computed baseTypeSeq of " + tsym.tpe + " " + parents + ": "+elems.toString)//DEBUG
+ new BaseTypeSeq(elems)
+ }
+/*
var j = 0
while (j < btsSize) {
elems(j) match {
@@ -139,7 +162,7 @@ trait BaseTypeSeqs {
elems(j) = mergePrefixAndArgs(variants, -1, maxBaseTypeSeqDepth(variants) + LubGlbMargin) match {
case Some(tp0) => tp0
case None => throw new TypeError(
- "the type intersection "+(tp.parents mkString " with ")+" is malformed"+
+ "the type intersection "+(parents mkString " with ")+" is malformed"+
"\n --- because ---"+
"\n no common type instance of base types "+(variants mkString ", and ")+" exists.")
}
@@ -147,6 +170,7 @@ trait BaseTypeSeqs {
}
j += 1
}
- tp.baseTypeSeqCache // todo: needed, or can be unit?
+ tp.baseTypeSeqCache
}
+*/
}
diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala
index efe789e2e6..2eeecbace6 100644
--- a/src/compiler/scala/tools/nsc/symtab/Types.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Types.scala
@@ -121,7 +121,7 @@ trait Types {
}
/** A proxy for a type (identified by field `underlying') that forwards most
- * operations to it (for exceptions, see WrappingProxy, which forwards even more operations.
+ * operations to it (for exceptions, see WrappingProxy, which forwards even more operations).
* every operation that is overridden for some kind of types should be forwarded.
*/
trait SimpleTypeProxy extends Type {
@@ -1035,7 +1035,10 @@ trait Types {
if (util.Statistics.enabled)
compoundBaseTypeSeqCount += 1
baseTypeSeqCache = undetBaseTypeSeq
- baseTypeSeqCache = memo(compoundBaseTypeSeq(this))(_.baseTypeSeq updateHead typeSymbol.tpe)
+ baseTypeSeqCache = memo(compoundBaseTypeSeq(typeSymbol, parents))(_.baseTypeSeq updateHead typeSymbol.tpe)
+// println("normalizing baseTypeSeq of "+typeSymbol+"/"+parents+": "+baseTypeSeqCache)//DEBUG
+ baseTypeSeqCache.normalize(parents)
+// println("normalized baseTypeSeq of "+typeSymbol+"/"+parents+": "+baseTypeSeqCache)//DEBUG
}
//Console.println("baseTypeSeq(" + typeSymbol + ") = " + List.fromArray(baseTypeSeqCache));//DEBUG
}
@@ -1469,7 +1472,6 @@ A type's typeSymbol should never be inspected directly.
}
}
- }
if (baseTypeSeqCache == undetBaseTypeSeq)
throw new TypeError("illegal cyclic inheritance involving " + sym)
baseTypeSeqCache