summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@epfl.ch>2007-07-20 09:22:00 +0000
committerAdriaan Moors <adriaan.moors@epfl.ch>2007-07-20 09:22:00 +0000
commit62d7f4c35a302d65fb3b17c8b15f3f1c86601639 (patch)
treef73982c7a8d8314112db7227c24ced183f99928b /src
parent475937a041159d49d03f3f6a199e7c8416d0ba8e (diff)
downloadscala-62d7f4c35a302d65fb3b17c8b15f3f1c86601639.tar.gz
scala-62d7f4c35a302d65fb3b17c8b15f3f1c86601639.tar.bz2
scala-62d7f4c35a302d65fb3b17c8b15f3f1c86601639.zip
quick fix for the first part of bug1210 (compil...
quick fix for the first part of bug1210 (compiler loops in normalize), so that the other problem is revealed: escaping variable is not detected. For the first part, I added an ugly explicit if to `normalize` -- I haven't figured out why it's needed yet.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Types.scala33
1 files changed, 18 insertions, 15 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala
index 4093144d12..b78cbb5583 100644
--- a/src/compiler/scala/tools/nsc/symtab/Types.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Types.scala
@@ -1321,22 +1321,23 @@ A type's typeSymbol should never be inspected directly.
private def argsMaybeDummy = if (isHigherKinded) higherKindedArgs else args
override def normalize =
- if (sym.isAliasType) {
- if (sym.info.typeParams.length == args.length) // beta-reduce -- check if the info has been loaded, if not, the arity check is meaningless
- // Martin to Adriaan: I believe sym.info.isComplete is redundant here
- // @M: correct: it was a remnant of a previous fix for the problem in the last else {} branch
- transform(sym.info.resultType).normalize // cycles have been checked in typeRef
- else if (isHigherKinded)
- PolyType(typeParams, transform(sym.info.resultType).normalize)
- else {
- //log("Error: normalizing "+sym.rawname+" with mismatch between type params "+sym.info.typeParams+" and args "+args)
- //this
+ if (sym.isAliasType) { // beta-reduce
+ if (!isHigherKinded /*degenerate case, see comments below*/ ||
+ sym.info.typeParams.length == args.length) {
+ //transform(sym.info.resultType).normalize // cycles have been checked in typeRef
+ val xform=transform(sym.info.resultType)
+ if(xform eq this) xform else xform.normalize // @M TODO: why is this necessary?
+ }/* else if (!isHigherKinded) { // sym.info.typeParams.length != args.length
+ log("Error: normalizing "+sym.rawname+" with mismatch between type params "+sym.info.typeParams+" and args "+args)
transform(sym.info.resultType).normalize // technically wrong, but returning `this' is even worse (cycle!)
// only happens when compiling `val x: Class' with -Xgenerics,
// when `type Class = java.lang.Class' has already been compiled (without -Xgenerics)
- }
- } else if (isHigherKinded) {
- PolyType(typeParams, typeRef(pre, sym, higherKindedArgs)) // @M TODO: transform?
+ }*/ else PolyType(typeParams, transform(sym.info.resultType).normalize)
+ // @M TODO: should not use PolyType, as that's the type of a polymorphic value -- we really want a type *function*
+ } else if (isHigherKinded) { // eta-expand
+ // @M TODO: should not use PolyType, as that's the type of a polymorphic value -- we really want a type *function*
+ // @M TODO: transform?
+ PolyType(typeParams, typeRef(pre, sym, higherKindedArgs))
} else super.normalize // @M TODO: transform?
override def decls: Scope = {
@@ -1456,8 +1457,10 @@ A type's typeSymbol should never be inspected directly.
* a parameterless method type.
* (@M: note that polymorphic nullary methods have non-empty tparams,
* e.g., isInstanceOf or def makeList[T] = new List[T].
- * Ideally, there would be a NullaryMethodType, so that higher-kinded types
- * could use PolyType instead of TypeRef with empty args)
+ * Ideally, there would be a NullaryMethodType, but since the only polymorphic values are methods, it's not that problematic.
+ * More pressingly, we should add a TypeFunction type for anonymous type constructors -- for now, PolyType is used in:
+ * - normalize: for eta-expansion of type aliases
+ * - abstractTypeSig )
*/
case class PolyType(override val typeParams: List[Symbol], override val resultType: Type)
extends Type {