diff options
author | Paul Phillips <paulp@improving.org> | 2010-09-30 20:52:47 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-09-30 20:52:47 +0000 |
commit | d3c453d15c318c7c8da73d6a2ea2ae59a14da196 (patch) | |
tree | e796712c319709c56d7aa756526e7b1d57bff7ba | |
parent | 0f2808227be055fb4603e7a0600a063a5756dfa0 (diff) | |
download | scala-d3c453d15c318c7c8da73d6a2ea2ae59a14da196.tar.gz scala-d3c453d15c318c7c8da73d6a2ea2ae59a14da196.tar.bz2 scala-d3c453d15c318c7c8da73d6a2ea2ae59a14da196.zip |
While trying to come to an understanding with #...
While trying to come to an understanding with #3869 I had one of those
"what are we doing" moments regarding the reams of output generated
under -Ydebug. We have all these places where extra
info is logged under -Ydebug -- like "if (debug) log(...)" -- and if
you try for those you are also saddled with all these irrelevant places
which instead say if (debug) Console.println(...).
I changed about every one of them to send it to log() instead. So if you
were enjoying that 600 MB of debugging output when you compile "goodbye
world", you can have it back and then some with -Ylog:all. Until then,
enjoy the calm, quiet competence of the new -Ydebug.
Also herein: raised default ANT_OPTS permgen because I can no longer
build a dist with the former defaults, and gave some synthetics a better
home in StdNames.
No review (but if anyone just can't live without some particular piece
of output every single time -Ydebug is given, I can put it back.)
16 files changed, 159 insertions, 84 deletions
@@ -184,7 +184,7 @@ PROPERTIES <!-- if ANT_OPTS is already set by the environment, it will be unaltered, but if it is unset it will take this default value. --> - <property name="env.ANT_OPTS" value="-Xms1536M -Xmx1536M -Xss1M -XX:MaxPermSize=128M -XX:+UseParallelGC" /> + <property name="env.ANT_OPTS" value="-Xms1536M -Xmx1536M -Xss1M -XX:MaxPermSize=192M -XX:+UseParallelGC" /> <!-- to find max heap usage: -Xaprof ; currently at 980M for locker.comp --> <echo message="Using ANT_OPTS: ${env.ANT_OPTS}" /> diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index 6d9bc2976a..a52235fd90 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -255,7 +255,11 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable abstract class GlobalPhase(prev: Phase) extends Phase(prev) { phaseWithId(id) = this - def run { currentRun.units foreach applyPhase } + + def run { + echoPhaseSummary(this) + currentRun.units foreach applyPhase + } def apply(unit: CompilationUnit): Unit @@ -276,7 +280,9 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable } final def applyPhase(unit: CompilationUnit) { - if (settings.debug.value) inform("[running phase " + name + " on " + unit + "]") + if (doEchoFilenames) + inform("[running phase " + name + " on " + unit + "]") + val unit0 = currentRun.currentUnit try { currentRun.currentUnit = unit @@ -586,6 +592,14 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable */ override def currentRunId = curRunId + def currentRunSize = currentRun.unitbufSize + def doEchoFilenames = settings.debug.value && (settings.verbose.value || currentRunSize < 5) + def echoPhaseSummary(ph: Phase) = { + /** Only output a summary message under debug if we aren't echoing each file. */ + if (settings.debug.value && !doEchoFilenames) + inform("[running phase " + ph.name + " on " + currentRunSize + " compilation units]") + } + /** A Run is a single execution of the compiler on a sets of units */ class Run { @@ -693,10 +707,14 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable private var unitbuf = new ListBuffer[CompilationUnit] var compiledFiles = new HashSet[String] + private var _unitbufSize = 0 + def unitbufSize = _unitbufSize + /** add unit to be compiled in this run */ private def addUnit(unit: CompilationUnit) { // unit.parseSettings() unitbuf += unit + _unitbufSize += 1 // counting as they're added so size is cheap compiledFiles += unit.source.file.path } diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index 4ac6aea923..b414981665 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -200,21 +200,19 @@ self => accept(EOF) def mainModuleName = settings.script.value + /** If there is only a single object template in the file and it has a + * suitable main method, we will use it rather than building another object + * around it. Since objects are loaded lazily the whole script would have + * been a no-op, so we're not taking much liberty. + */ def searchForMain(): Option[Tree] = { - /** If there is only a single object template in the file and it has a - * suitable main method, we will use it rather than building another object - * around it. Since objects are loaded lazily the whole script would have - * been a no-op, so we're not taking much liberty. - */ - val MainName: Name = newTermName("main") - /** Have to be fairly liberal about what constitutes a main method since * nothing has been typed yet - for instance we can't assume the parameter * type will look exactly like "Array[String]" as it could have been renamed * via import, etc. */ def isMainMethod(t: Tree) = t match { - case DefDef(_, MainName, Nil, List(_), _, _) => true + case DefDef(_, nme.main, Nil, List(_), _, _) => true case _ => false } /** For now we require there only be one top level object. */ @@ -268,11 +266,11 @@ self => ) // def main - def mainParamType = AppliedTypeTree(Ident("Array".toTypeName), List(Ident("String".toTypeName))) + def mainParamType = AppliedTypeTree(Ident(nme.Array.toTypeName), List(Ident(nme.String.toTypeName))) def mainParameter = List(ValDef(Modifiers(Flags.PARAM), "argv", mainParamType, EmptyTree)) def mainSetArgv = List(ValDef(NoMods, "args", TypeTree(), Ident("argv"))) def mainNew = makeNew(Nil, emptyValDef, stmts, List(Nil), NoPosition, NoPosition) - def mainDef = DefDef(NoMods, "main", Nil, List(mainParameter), scalaDot(nme.Unit.toTypeName), Block(mainSetArgv, mainNew)) + def mainDef = DefDef(NoMods, nme.main, Nil, List(mainParameter), scalaDot(nme.Unit.toTypeName), Block(mainSetArgv, mainNew)) // object Main def moduleName = ScriptRunner scriptMain settings @@ -1143,7 +1141,7 @@ self => case WHILE => val start = in.offset atPos(in.skipToken()) { - val lname: Name = freshName(o2p(start), "while$") + val lname: Name = freshName(o2p(start), nme.WHILE_PREFIX) val cond = condExpr() newLinesOpt() val body = expr() @@ -1152,7 +1150,7 @@ self => case DO => val start = in.offset atPos(in.skipToken()) { - val lname: Name = freshName(o2p(start), "doWhile$") + val lname: Name = freshName(o2p(start), nme.DO_WHILE_PREFIX) val body = expr() if (isStatSep) in.nextToken() accept(WHILE) diff --git a/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala b/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala index 32c0d936b2..bdcee1cba7 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala @@ -15,7 +15,10 @@ import backend.icode.analysis.ProgramPoint trait BasicBlocks { self: ICodes => + import opcodes._ + import global.{ settings, log, nme } + import nme.isExceptionResultName /** This class represents a basic block. Each * basic block contains a list of instructions that are @@ -249,7 +252,19 @@ trait BasicBlocks { } */ assert(!closed || ignore, "BasicBlock closed") - if (!ignore) { + if (ignore) { + if (settings.debug.value) { + /** Trying to pin down what it's likely to see after a block has been + * put into ignore mode so we hear about it if there's a problem. + */ + instr match { + case JUMP(_) | RETURN(_) | THROW() | SCOPE_EXIT(_) => // ok + case STORE_LOCAL(local) if isExceptionResultName(local.sym.name) => // ok + case x => log("Ignoring instruction, possibly at our peril, at " + pos + ": " + x) + } + } + } + else { instr.setPos(pos) instructionList = instr :: instructionList _lastInstruction = instr @@ -318,7 +333,10 @@ trait BasicBlocks { * added to this basic block. It makes the generation of THROW * and RETURNs easier. */ - def enterIgnoreMode = ignore = true + def enterIgnoreMode = { + log("Entering ignore mode in " + fullString) + ignore = true + } def exitIgnoreMode { assert(ignore, "Exit ignore mode when not in ignore mode.") diff --git a/src/compiler/scala/tools/nsc/backend/icode/Checkers.scala b/src/compiler/scala/tools/nsc/backend/icode/Checkers.scala index a4c186791a..bb09030c17 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/Checkers.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/Checkers.scala @@ -635,9 +635,7 @@ abstract class Checkers { //////////////// Error reporting ///////////////////////// def error(msg: String) { - Console.println("!! ICode checker fatality in " + method + " at:") - Console.println(blockAsString(basicBlock)) - Checkers.this.global.error(method + ":\n " + msg) + Checkers.this.global.error("!! ICode checker fatality in " + method + " at:" + blockAsString(basicBlock) + ":\n " + msg) } def error(msg: String, stack: TypeStack) { diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala index df1e604081..903802759d 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala @@ -617,19 +617,20 @@ abstract class GenICode extends SubComponent { val resCtx: Context = tree match { case LabelDef(name, params, rhs) => val ctx1 = ctx.newBlock - if (isLoopHeaderLabel(name)) - ctx1.bb.loopHeader = true; + if (nme.isLoopHeaderLabel(name)) + ctx1.bb.loopHeader = true ctx1.labels.get(tree.symbol) match { case Some(label) => + log("Found existing label for " + tree.symbol) label.anchor(ctx1.bb) label.patch(ctx.method.code) case None => - ctx1.labels += (tree.symbol -> (new Label(tree.symbol) anchor ctx1.bb setParams (params map (_.symbol)))); + val pair = (tree.symbol -> (new Label(tree.symbol) anchor ctx1.bb setParams (params map (_.symbol)))) + log("Adding label " + tree.symbol + " in genLoad.") + ctx1.labels += pair ctx.method.addLocals(params map (p => new Local(p.symbol, toTypeKind(p.symbol.info), false))); - if (settings.debug.value) - log("Adding label " + tree.symbol); } ctx.bb.closeWith(JUMP(ctx1.bb), tree.pos) @@ -666,31 +667,39 @@ abstract class GenICode extends SubComponent { case Return(expr) => val returnedKind = toTypeKind(expr.tpe) - var ctx1 = genLoad(expr, ctx, returnedKind) - val oldcleanups = ctx1.cleanups - lazy val tmp = ctx1.makeLocal(tree.pos, expr.tpe, "tmp") - var saved = false - - for (op <- ctx1.cleanups) op match { - case MonitorRelease(m) => - if (settings.debug.value) log("removing " + m + " from cleanups: " + ctx1.cleanups) - ctx1.bb.emit(LOAD_LOCAL(m)) - ctx1.bb.emit(MONITOR_EXIT()) - ctx1.exitSynchronized(m) - case Finalizer(f) => - if (settings.debug.value) log("removing " + f + " from cleanups: " + ctx1.cleanups) - if (returnedKind != UNIT && mayCleanStack(f) && !saved) { - ctx1.bb.emit(STORE_LOCAL(tmp)) - saved = true - } - // we have to run this without the same finalizer in - // the list, otherwise infinite recursion happens for - // finalizers that contain 'return' - ctx1 = genLoad(f, ctx1.removeFinalizer(f), UNIT) + log("Return(" + expr + ") with returnedKind = " + returnedKind) + + var ctx1 = genLoad(expr, ctx, returnedKind) + lazy val tmp = ctx1.makeLocal(tree.pos, expr.tpe, "tmp") + val saved = savingCleanups(ctx1) { + ctx1.cleanups exists { + case MonitorRelease(m) => + if (settings.debug.value) + log("removing " + m + " from cleanups: " + ctx1.cleanups) + ctx1.bb.emit(Seq(LOAD_LOCAL(m), MONITOR_EXIT())) + ctx1.exitSynchronized(m) + false + case Finalizer(f) => + if (settings.debug.value) + log("removing " + f + " from cleanups: " + ctx1.cleanups) + + val saved = returnedKind != UNIT && mayCleanStack(f) && { + log("Emitting STORE_LOCAL for " + tmp + " to save finalizer.") + ctx1.bb.emit(STORE_LOCAL(tmp)) + true + } + // we have to run this without the same finalizer in + // the list, otherwise infinite recursion happens for + // finalizers that contain 'return' + ctx1 = genLoad(f, ctx1.removeFinalizer(f), UNIT) + saved + } } - ctx1.cleanups = oldcleanups - if (saved) ctx1.bb.emit(LOAD_LOCAL(tmp)) + if (saved) { + log("Emitting LOAD_LOCAL for " + tmp + " after saving finalizer.") + ctx1.bb.emit(LOAD_LOCAL(tmp)) + } adapt(returnedKind, ctx1.method.returnType, ctx1, tree.pos) ctx1.bb.emit(RETURN(ctx.method.returnType), tree.pos) ctx1.bb.enterIgnoreMode @@ -1753,9 +1762,6 @@ abstract class GenICode extends SubComponent { def getMaxType(ts: List[Type]): TypeKind = ts map toTypeKind reduceLeft (_ maxType _) - def isLoopHeaderLabel(name: Name): Boolean = - name.startsWith("while$") || name.startsWith("doWhile$") - /** Tree transformer that duplicates code and at the same time creates * fresh symbols for existing labels. Since labels may be used before * they are defined (forward jumps), all labels found are mapped to fresh @@ -1801,7 +1807,9 @@ abstract class GenICode extends SubComponent { val tree = treeCopy.LabelDef(t, newSym.name, params, transform(rhs)) tree.symbol = newSym - ctx.labels += (newSym -> (new Label(newSym) setParams (params map (_.symbol)))) + val pair = (newSym -> (new Label(newSym) setParams (params map (_.symbol)))) + log("Added " + pair + " to labels.") + ctx.labels += pair ctx.method.addLocals(params map (p => new Local(p.symbol, toTypeKind(p.symbol.info), false))) tree @@ -1827,6 +1835,12 @@ abstract class GenICode extends SubComponent { (new DuplicateLabels(boundLabels))(targetCtx, finalizer) } + def savingCleanups[T](ctx: Context)(body: => T): T = { + val saved = ctx.cleanups + try body + finally ctx.cleanups = saved + } + /** * The Context class keeps information relative to the current state * in code generation diff --git a/src/compiler/scala/tools/nsc/backend/icode/Members.scala b/src/compiler/scala/tools/nsc/backend/icode/Members.scala index 9d9e3c92e4..8001c30efd 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/Members.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/Members.scala @@ -207,9 +207,9 @@ trait Members { self: ICodes => } toSet if (code != null) { - Console.println("[checking locals of " + this + "]") + log("[checking locals of " + this + "]") locals filterNot localsSet foreach { l => - Console.println("Local " + l + " is not declared in " + this) + log("Local " + l + " is not declared in " + this) } } } diff --git a/src/compiler/scala/tools/nsc/symtab/StdNames.scala b/src/compiler/scala/tools/nsc/symtab/StdNames.scala index aa47441a1a..eee61a4312 100644 --- a/src/compiler/scala/tools/nsc/symtab/StdNames.scala +++ b/src/compiler/scala/tools/nsc/symtab/StdNames.scala @@ -166,6 +166,12 @@ trait StdNames extends reflect.generic.StdNames { self: SymbolTable => def getterName(name: Name): Name = if (isLocalName(name)) localToGetter(name) else name; + def isExceptionResultName(name: Name) = + (name startsWith EXCEPTION_RESULT_PREFIX) + + def isLoopHeaderLabel(name: Name): Boolean = + (name startsWith WHILE_PREFIX) || (name startsWith DO_WHILE_PREFIX) + def isImplClassName(name: Name): Boolean = name endsWith IMPL_CLASS_SUFFIX; @@ -192,6 +198,11 @@ trait StdNames extends reflect.generic.StdNames { self: SymbolTable => /** The name of bitmaps for initialized lazy vals. */ def bitmapName(n: Int): Name = newTermName("bitmap$" + n) + /** The label prefixes for generated while and do loops. */ + val WHILE_PREFIX = "while$" + val DO_WHILE_PREFIX = "doWhile$" + val EXCEPTION_RESULT_PREFIX = "exceptionResult" + val ERROR = newTermName("<error>") val LOCALCHILD = newTypeName("<local child>") diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala index f014dfde9c..d5dfc37a31 100644 --- a/src/compiler/scala/tools/nsc/symtab/Types.scala +++ b/src/compiler/scala/tools/nsc/symtab/Types.scala @@ -3720,17 +3720,26 @@ A type's typeSymbol should never be inspected directly. def corresponds(sym1: Symbol, sym2: Symbol): Boolean = sym1.name == sym2.name && (sym1.isPackageClass || corresponds(sym1.owner, sym2.owner)) if (!corresponds(sym.owner, rebind0.owner)) { - if (settings.debug.value) Console.println("ADAPT1 pre = "+pre+", sym = "+sym+sym.locationString+", rebind = "+rebind0+rebind0.locationString) + if (settings.debug.value) + log("ADAPT1 pre = "+pre+", sym = "+sym+sym.locationString+", rebind = "+rebind0+rebind0.locationString) val bcs = pre.baseClasses.dropWhile(bc => !corresponds(bc, sym.owner)); if (bcs.isEmpty) assert(pre.typeSymbol.isRefinementClass, pre) // if pre is a refinementclass it might be a structural type => OK to leave it in. else rebind0 = pre.baseType(bcs.head).member(sym.name) - if (settings.debug.value) Console.println("ADAPT2 pre = "+pre+", bcs.head = "+bcs.head+", sym = "+sym+sym.locationString+", rebind = "+rebind0+(if (rebind0 == NoSymbol) "" else rebind0.locationString)) + if (settings.debug.value) log( + "ADAPT2 pre = " + pre + + ", bcs.head = " + bcs.head + + ", sym = " + sym+sym.locationString + + ", rebind = " + rebind0 + ( + if (rebind0 == NoSymbol) "" + else rebind0.locationString + ) + ) } val rebind = rebind0.suchThat(sym => sym.isType || sym.isStable) if (rebind == NoSymbol) { - if (settings.debug.value) Console.println("" + phase + " " +phase.flatClasses+sym.owner+sym.name+" "+sym.isType) + if (settings.debug.value) log("" + phase + " " +phase.flatClasses+sym.owner+sym.name+" "+sym.isType) throw new MalformedType(pre, sym.nameString) } rebind @@ -5383,13 +5392,13 @@ A type's typeSymbol should never be inspected directly. // @M sometimes hkargs != arg.typeParams, the symbol and the type may have very different type parameters val hkparams = param.typeParams - if(settings.debug.value) { - println("checkKindBoundsHK expected: "+ param +" with params "+ hkparams +" by definition in "+ paramowner) - println("checkKindBoundsHK supplied: "+ arg +" with params "+ hkargs +" from "+ owner) - println("checkKindBoundsHK under params: "+ underHKParams +" with args "+ withHKArgs) + if (settings.debug.value) { + log("checkKindBoundsHK expected: "+ param +" with params "+ hkparams +" by definition in "+ paramowner) + log("checkKindBoundsHK supplied: "+ arg +" with params "+ hkargs +" from "+ owner) + log("checkKindBoundsHK under params: "+ underHKParams +" with args "+ withHKArgs) } - if(hkargs.length != hkparams.length) { + if (hkargs.length != hkparams.length) { if(arg == AnyClass || arg == NothingClass) (Nil, Nil, Nil) // Any and Nothing are kind-overloaded else {error = true; (List((arg, param)), Nil, Nil)} // shortcut: always set error, whether explainTypesOrNot } else { @@ -5414,12 +5423,12 @@ A type's typeSymbol should never be inspected directly. if (!(bindHKParams(transformedBounds(hkparam, paramowner)) <:< transform(hkarg.info.bounds, owner))) stricterBound(hkarg, hkparam) - if(settings.debug.value) { - println("checkKindBoundsHK base case: "+ hkparam +" declared bounds: "+ transformedBounds(hkparam, paramowner) +" after instantiating earlier hkparams: "+ bindHKParams(transformedBounds(hkparam, paramowner))) - println("checkKindBoundsHK base case: "+ hkarg +" has bounds: "+ transform(hkarg.info.bounds, owner)) + if (settings.debug.value) { + log("checkKindBoundsHK base case: "+ hkparam +" declared bounds: "+ transformedBounds(hkparam, paramowner) +" after instantiating earlier hkparams: "+ bindHKParams(transformedBounds(hkparam, paramowner))) + log("checkKindBoundsHK base case: "+ hkarg +" has bounds: "+ transform(hkarg.info.bounds, owner)) } } else { - if(settings.debug.value) println("checkKindBoundsHK recursing to compare params of "+ hkparam +" with "+ hkarg) + if(settings.debug.value) log("checkKindBoundsHK recursing to compare params of "+ hkparam +" with "+ hkarg) val (am, vm, sb) = checkKindBoundsHK(hkarg.typeParams, hkarg, hkparam, paramowner, underHKParams ++ hkparam.typeParams, withHKArgs ++ hkarg.typeParams) arityMismatches(am) varianceMismatches(vm) diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala index 073fd3d4b2..602b3a8637 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala @@ -888,7 +888,7 @@ abstract class ClassfileParser { case nme.ScalaSignatureATTR => if (!isScalaAnnot) { if (settings.debug.value) - global.inform("warning: symbol " + sym.fullName + " has pickled signature in attribute") + log("warning: symbol " + sym.fullName + " has pickled signature in attribute") unpickler.unpickle(in.buf, in.bp, clazz, staticModule, in.file.toString()) } in.skip(attrLen) @@ -916,7 +916,7 @@ abstract class ClassfileParser { throw new RuntimeException("Scala class file does not contain Scala annotation") } if (settings.debug.value) - global.inform("" + sym + "; annotations = " + sym.rawAnnotations) + log("" + sym + "; annotations = " + sym.rawAnnotations) } else in.skip(attrLen) @@ -1033,8 +1033,8 @@ abstract class ClassfileParser { case f: FatalError => throw f // don't eat fatal errors, they mean a class was not found case ex: Throwable => if (settings.debug.value) - global.inform("dropping annotation on " + sym + - ", an error occured during parsing (e.g. annotation class not found)") + log("dropping annotation on " + sym + ", an error occured during parsing (e.g. annotation class not found)") + None // ignore malformed annotations ==> t1135 } diff --git a/src/compiler/scala/tools/nsc/transform/CleanUp.scala b/src/compiler/scala/tools/nsc/transform/CleanUp.scala index db577d04a1..0739deec5f 100644 --- a/src/compiler/scala/tools/nsc/transform/CleanUp.scala +++ b/src/compiler/scala/tools/nsc/transform/CleanUp.scala @@ -501,8 +501,10 @@ abstract class CleanUp extends Transform with ast.TreeDSL { ) case _ => "" } - Console.printf("""Dynamically application '%s.%s(%s)' %s - resulting code: '%s'""", - List(qual, ad.symbol.name, paramsToString(params), mstr, t) map (_.toString) : _* + log( + """Dynamically application '%s.%s(%s)' %s - resulting code: '%s'""".format( + qual, ad.symbol.name, paramsToString(params), mstr, t + ) ) } @@ -554,8 +556,7 @@ abstract class CleanUp extends Transform with ast.TreeDSL { case theTry @ Try(block, catches, finalizer) if theTry.tpe.typeSymbol != definitions.UnitClass && theTry.tpe.typeSymbol != definitions.NothingClass => val tpe = theTry.tpe.widen - val tempVar = currentOwner.newValue(theTry.pos, unit.fresh.newName(theTry.pos, "exceptionResult")) - .setInfo(tpe).setFlag(Flags.MUTABLE) + val tempVar = currentOwner.newVariable(theTry.pos, unit.fresh.newName(theTry.pos, nme.EXCEPTION_RESULT_PREFIX)).setInfo(tpe) def assignBlock(rhs: Tree) = super.transform(BLOCK(Ident(tempVar) === transform(rhs))) val newBlock = assignBlock(block) @@ -563,10 +564,11 @@ abstract class CleanUp extends Transform with ast.TreeDSL { (CASE(super.transform(pattern)) IF (super.transform(guard))) ==> assignBlock(body) val newTry = Try(newBlock, newCatches, super.transform(finalizer)) - localTyper typed { BLOCK(VAL(tempVar) === EmptyTree, newTry, Ident(tempVar)) } + typedWithPos(theTry.pos)(BLOCK(VAL(tempVar) === EmptyTree, newTry, Ident(tempVar))) /* Adds @serializable annotation to anonymous function classes */ case cdef @ ClassDef(mods, name, tparams, impl) => + /** XXX This check is overly specific and bound to break if it hasn't already. */ if (settings.target.value == "jvm-1.5") { val sym = cdef.symbol // is this an anonymous function class? diff --git a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala index d22930c336..420ec6b3ba 100644 --- a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala +++ b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala @@ -1193,7 +1193,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { val tree1 = addBody(ddef, target) (new ChangeOwnerTraverser(target, tree1.symbol))(tree1.rhs) if (settings.debug.value) - println("changed owners, now: " + tree1) + log("changed owners, now: " + tree1) val DefDef(mods, name, tparams, vparamss, tpt, rhs) = tree1 treeCopy.DefDef(tree1, mods, name, tparams, vparamss, tpt, transform(rhs)) diff --git a/src/compiler/scala/tools/nsc/typechecker/Analyzer.scala b/src/compiler/scala/tools/nsc/typechecker/Analyzer.scala index e039b00ee8..0e2920a852 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Analyzer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Analyzer.scala @@ -78,6 +78,7 @@ trait Analyzer extends AnyRef resetTyper() // this does not in fact to the reset for each compilation run! override def run { val start = startTimer(typerNanos) + global.echoPhaseSummary(this) currentRun.units foreach applyPhase stopTimer(typerNanos, start) } diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index 5c90a69c94..d7b8d6f2c5 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -966,7 +966,8 @@ abstract class RefChecks extends InfoTransform { typed(ValDef(vsym, EmptyTree)) :: typed(lazyDef) :: Nil } else { if (tree.symbol.isLocal && index <= currentLevel.maxindex && !tree.symbol.hasFlag(LAZY)) { - if (settings.debug.value) Console.println(currentLevel.refsym); + if (settings.debug.value) + Console.println(currentLevel.refsym) unit.error(currentLevel.refpos, "forward reference extends over definition of " + tree.symbol); } List(tree1) diff --git a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala index 976c063efc..f4f089931e 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala @@ -201,7 +201,7 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT sym.alias) setPos tree.pos } if (settings.debug.value) - Console.println("alias replacement: " + tree + " ==> " + result);//debug + log("alias replacement: " + tree + " ==> " + result);//debug localTyper.typed(gen.maybeMkAsInstanceOf(transformSuperSelect(result), sym.tpe, sym.alias.tpe, true)) } else mayNeedProtectedAccessor(sel, List(EmptyTree), false) diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 742f792e84..619aad94dc 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -1866,11 +1866,8 @@ trait Typers { self: Analyzer => } } - private def isLoopHeaderLabel(name: Name): Boolean = - name.startsWith("while$") || name.startsWith("doWhile$") - def typedLabelDef(ldef: LabelDef): LabelDef = { - if (!isLoopHeaderLabel(ldef.symbol.name) || phase.id > currentRun.typerPhase.id) { + if (!nme.isLoopHeaderLabel(ldef.symbol.name) || phase.id > currentRun.typerPhase.id) { val restpe = ldef.symbol.tpe.resultType val rhs1 = typed(ldef.rhs, restpe) ldef.params foreach (param => param.tpe = param.symbol.tpe) @@ -3602,7 +3599,14 @@ trait Typers { self: Analyzer => if (tree1 != EmptyTree) return typed1(tree1, mode, pt) } - if (settings.debug.value) Console.err.println("qual = "+qual+":"+qual.tpe+"\nSymbol="+qual.tpe.termSymbol+"\nsymbol-info = "+qual.tpe.termSymbol.info+"\nscope-id = "+qual.tpe.termSymbol.info.decls.hashCode()+"\nmembers = "+qual.tpe.members+"\nname = "+name+"\nfound = "+sym+"\nowner = "+context.enclClass.owner) + if (settings.debug.value) { + log( + "qual = "+qual+":"+qual.tpe+ + "\nSymbol="+qual.tpe.termSymbol+"\nsymbol-info = "+qual.tpe.termSymbol.info+ + "\nscope-id = "+qual.tpe.termSymbol.info.decls.hashCode()+"\nmembers = "+qual.tpe.members+ + "\nname = "+name+"\nfound = "+sym+"\nowner = "+context.enclClass.owner + ) + } def makeErrorTree = { val tree1 = tree match { @@ -4195,7 +4199,8 @@ trait Typers { self: Analyzer => def typed(tree: Tree, mode: Int, pt: Type): Tree = { indentTyping() def dropExistential(tp: Type): Type = tp match { case ExistentialType(tparams, tpe) => - if (settings.debug.value) println("drop ex "+tree+" "+tp) + if (settings.debug.value) + log("Dropping existential: " + tree + " " + tp) new SubstWildcardMap(tparams).apply(tp) case TypeRef(_, sym, _) if sym.isAliasType => val tp0 = tp.normalize |