diff options
author | Paul Phillips <paulp@improving.org> | 2011-06-06 23:53:50 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-06-06 23:53:50 +0000 |
commit | b8575e9636004b4abfbd5cd4b0a71c39bf8b1127 (patch) | |
tree | f1c107751ae890f3c0b19e349fc2a32481c84658 /src/compiler/scala/reflect/internal/Types.scala | |
parent | 29cdb5837ca05a883093bb0e7ddfac264c84afea (diff) | |
download | scala-b8575e9636004b4abfbd5cd4b0a71c39bf8b1127.tar.gz scala-b8575e9636004b4abfbd5cd4b0a71c39bf8b1127.tar.bz2 scala-b8575e9636004b4abfbd5cd4b0a71c39bf8b1127.zip |
Proliferating the number of debugging modes bec...
Proliferating the number of debugging modes because it's still way
too hard to see what's going on in there. Until we get hubert's type
debugger with its whiz-bang whizbanginess, we'll have to struggle along
with somewhat prettier ascii. This introduces:
-Yinfer-debug
which tries to print in readable fashion what is happening in the
worlds of inference and implicit search. It should be made a bit more
complementary and less overlappy with -Ytyper-debug. No review.
Diffstat (limited to 'src/compiler/scala/reflect/internal/Types.scala')
-rw-r--r-- | src/compiler/scala/reflect/internal/Types.scala | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/src/compiler/scala/reflect/internal/Types.scala b/src/compiler/scala/reflect/internal/Types.scala index 572cb8d3a4..0e9f2c44e1 100644 --- a/src/compiler/scala/reflect/internal/Types.scala +++ b/src/compiler/scala/reflect/internal/Types.scala @@ -79,8 +79,6 @@ trait Types /*extends reflect.generic.Types*/ { self: SymbolTable => private var explainSwitch = false private final val emptySymbolSet = immutable.Set.empty[Symbol] - private final val alternativeNarrow = false - private final val LogPendingSubTypesThreshold = 50 private final val LogPendingBaseTypesThreshold = 50 private final val LogVolatileThreshold = 50 @@ -1931,8 +1929,16 @@ A type's typeSymbol should never be inspected directly. case TypeRef(_, RepeatedParamClass, arg :: _) => return arg + "*" case TypeRef(_, ByNameParamClass, arg :: _) => return "=> " + arg case _ => - if (isFunctionType(this)) - return normalize.typeArgs.init.mkString("(", ", ", ")") + " => " + normalize.typeArgs.last + if (isFunctionType(this)) { + val targs = normalize.typeArgs + // Aesthetics: printing Function1 as T => R rather than (T) => R + val paramlist = targs.init match { + case Nil => "()" + case x :: Nil => "" + x + case xs => xs.mkString("(", ", ", ")") + } + return paramlist + " => " + targs.last + } else if (isTupleTypeOrSubtype(this)) return normalize.typeArgs.mkString("(", ", ", if (hasLength(normalize.typeArgs, 1)) ",)" else ")") else if (sym.isAliasType && prefixChain.exists(_.termSymbol.isSynthetic)) { @@ -2281,10 +2287,12 @@ A type's typeSymbol should never be inspected directly. //@M // a TypeVar used to be a case class with only an origin and a constr - // then, constr became mutable (to support UndoLog, I guess), but pattern-matching returned the original constr0 (a bug) + // then, constr became mutable (to support UndoLog, I guess), + // but pattern-matching returned the original constr0 (a bug) // now, pattern-matching returns the most recent constr object TypeVar { - // encapsulate suspension so we can automatically link the suspension of cloned typevars to their original if this turns out to be necessary + // encapsulate suspension so we can automatically link the suspension of cloned + // typevars to their original if this turns out to be necessary def Suspension = new Suspension class Suspension { private val suspended = mutable.HashSet[TypeVar]() @@ -2293,17 +2301,20 @@ A type's typeSymbol should never be inspected directly. suspended += tv } def resumeAll(): Unit = { - for(tv <- suspended) { + for (tv <- suspended) { tv.suspended = false } - suspended.clear + suspended.clear() } } def unapply(tv: TypeVar): Some[(Type, TypeConstraint)] = Some((tv.origin, tv.constr)) def apply(origin: Type, constr: TypeConstraint) = new TypeVar(origin, constr, List(), List()) - def apply(tparam: Symbol) = new TypeVar(tparam.tpeHK, new TypeConstraint, List(), tparam.typeParams) // TODO why not initialise TypeConstraint with bounds of tparam? - def apply(origin: Type, constr: TypeConstraint, args: List[Type], params: List[Symbol]) = new TypeVar(origin, constr, args, params) + // TODO why not initialise TypeConstraint with bounds of tparam? + // @PP: I tried that, didn't work out so well for me. + def apply(tparam: Symbol) = new TypeVar(tparam.tpeHK, new TypeConstraint, List(), tparam.typeParams) + def apply(origin: Type, constr: TypeConstraint, args: List[Type], params: List[Symbol]) = + new TypeVar(origin, constr, args, params) } /** A class representing a type variable @@ -2438,7 +2449,8 @@ A type's typeSymbol should never be inspected directly. } } - def registerTypeEquality(tp: Type, typeVarLHS: Boolean): Boolean = { //println("regTypeEq: "+(safeToString, debugString(tp), typeVarLHS)) //@MDEBUG + def registerTypeEquality(tp: Type, typeVarLHS: Boolean): Boolean = { + //println("regTypeEq: "+(safeToString, debugString(tp), typeVarLHS)) //@MDEBUG def checkIsSameType(tp: Type) = if(typeVarLHS) constr.inst =:= tp else tp =:= constr.inst @@ -2600,8 +2612,7 @@ A type's typeSymbol should never be inspected directly. // Creators --------------------------------------------------------------- - /** Rebind symbol `sym' to an overriding member in type - * `pre'. + /** Rebind symbol `sym' to an overriding member in type `pre'. */ private def rebind(pre: Type, sym: Symbol): Symbol = { val owner = sym.owner @@ -2642,7 +2653,7 @@ A type's typeSymbol should never be inspected directly. } /** the canonical creator for a refined type with a given scope */ - def refinedType(parents: List[Type], owner: Symbol, decls: Scope, pos : Position): Type = { + def refinedType(parents: List[Type], owner: Symbol, decls: Scope, pos: Position): Type = { if (phase.erasedTypes) if (parents.isEmpty) ObjectClass.tpe else parents.head else { |