diff options
author | Paul Phillips <paulp@improving.org> | 2012-05-14 14:01:34 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-05-14 14:03:12 -0700 |
commit | e722bb1c70fed83257aa1c1fc9276ae8b7839c60 (patch) | |
tree | ee14de8d0ca96f517aa81d4910a042419d1ac53a | |
parent | b3f7bc996b7a59b951cd0f199a056b6ad99d153b (diff) | |
download | scala-e722bb1c70fed83257aa1c1fc9276ae8b7839c60.tar.gz scala-e722bb1c70fed83257aa1c1fc9276ae8b7839c60.tar.bz2 scala-e722bb1c70fed83257aa1c1fc9276ae8b7839c60.zip |
Debugging output tweaks.
And undeprecated Positional.
-rw-r--r-- | src/compiler/scala/tools/nsc/Global.scala | 2 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/LambdaLift.scala | 49 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/TailCalls.scala | 7 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Namers.scala | 2 | ||||
-rw-r--r-- | src/library/scala/util/parsing/input/Positional.scala | 1 | ||||
-rw-r--r-- | test/files/neg/tailrec-2.check | 2 |
6 files changed, 36 insertions, 27 deletions
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index 49a644ba3a..bdc5384078 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -998,7 +998,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter) extends Symb val info1 = formatExplain( "while compiling" -> currentSource.path, - "during phase" -> phase, + "during phase" -> ( if (globalPhase eq phase) phase else "global=%s, atPhase=%s".format(globalPhase, phase) ), "library version" -> scala.util.Properties.versionString, "compiler version" -> Properties.versionString, "reconstructed args" -> settings.recreateArgs.mkString(" ") diff --git a/src/compiler/scala/tools/nsc/transform/LambdaLift.scala b/src/compiler/scala/tools/nsc/transform/LambdaLift.scala index 618a1cbba4..718e58b855 100644 --- a/src/compiler/scala/tools/nsc/transform/LambdaLift.scala +++ b/src/compiler/scala/tools/nsc/transform/LambdaLift.scala @@ -108,28 +108,30 @@ abstract class LambdaLift extends InfoTransform { * } */ private def markFree(sym: Symbol, enclosure: Symbol): Boolean = { - debuglog("mark free: " + sym + " of " + sym.owner + " marked free in " + enclosure) - if (enclosure == sym.owner.logicallyEnclosingMember) true - else if (enclosure.isPackageClass || !markFree(sym, enclosure.skipConstructor.owner.logicallyEnclosingMember)) false - else { - val ss = symSet(free, enclosure) - if (!ss(sym)) { - ss addEntry sym - renamable addEntry sym - beforePickler { - // The param symbol in the MethodType should not be renamed, only the symbol in scope. This way, - // parameter names for named arguments are not changed. Example: without cloning the MethodType, - // def closure(x: Int) = { () => x } - // would have the signature - // closure: (x$1: Int)() => Int - if (sym.isParameter && sym.owner.info.paramss.exists(_ contains sym)) - sym.owner modifyInfo (_ cloneInfo sym.owner) + debuglog("mark free: " + sym.fullLocationString + " marked free in " + enclosure) + (enclosure == sym.owner.logicallyEnclosingMember) || { + debuglog("%s != %s".format(enclosure, sym.owner.logicallyEnclosingMember)) + if (enclosure.isPackageClass || !markFree(sym, enclosure.skipConstructor.owner.logicallyEnclosingMember)) false + else { + val ss = symSet(free, enclosure) + if (!ss(sym)) { + ss addEntry sym + renamable addEntry sym + beforePickler { + // The param symbol in the MethodType should not be renamed, only the symbol in scope. This way, + // parameter names for named arguments are not changed. Example: without cloning the MethodType, + // def closure(x: Int) = { () => x } + // would have the signature + // closure: (x$1: Int)() => Int + if (sym.isParameter && sym.owner.info.paramss.exists(_ contains sym)) + sym.owner modifyInfo (_ cloneInfo sym.owner) + } + changedFreeVars = true + debuglog("" + sym + " is free in " + enclosure); + if (sym.isVariable) sym setFlag CAPTURED } - changedFreeVars = true - debuglog("" + sym + " is free in " + enclosure); - if (sym.isVariable) sym setFlag CAPTURED + !enclosure.isClass } - !enclosure.isClass } } @@ -273,8 +275,11 @@ abstract class LambdaLift extends InfoTransform { if (ps.isEmpty) searchIn(enclosure.skipConstructor.owner) else ps.head } - debuglog("proxy " + sym + " in " + sym.owner + " from " + currentOwner.ownerChain.mkString(" -> ") + - " " + sym.owner.logicallyEnclosingMember) + debuglog("proxy %s from %s has logical enclosure %s".format( + sym.debugLocationString, + currentOwner.debugLocationString, + sym.owner.logicallyEnclosingMember.debugLocationString) + ) if (isSameOwnerEnclosure(sym)) sym else searchIn(currentOwner) diff --git a/src/compiler/scala/tools/nsc/transform/TailCalls.scala b/src/compiler/scala/tools/nsc/transform/TailCalls.scala index 9915f7e9fc..4c9d855413 100644 --- a/src/compiler/scala/tools/nsc/transform/TailCalls.scala +++ b/src/compiler/scala/tools/nsc/transform/TailCalls.scala @@ -154,7 +154,10 @@ abstract class TailCalls extends Transform { def isTransformed = isEligible && accessed(label) def tailrecFailure() = unit.error(failPos, "could not optimize @tailrec annotated " + method + ": " + failReason) - def newThis(pos: Position) = method.newValue(nme.THIS, pos, SYNTHETIC) setInfo currentClass.typeOfThis + def newThis(pos: Position) = logResult("Creating new `this` during tailcalls\n method: %s\n current class: %s".format( + method.ownerChain.mkString(" -> "), currentClass.ownerChain.mkString(" -> "))) { + method.newValue(nme.THIS, pos, SYNTHETIC) setInfo currentClass.typeOfThis + } override def toString(): String = ( "" + method.name + " tparams: " + tparams + " tailPos: " + tailPos + @@ -222,7 +225,7 @@ abstract class TailCalls extends Transform { if (!ctx.isEligible) fail("it is neither private nor final so can be overridden") else if (!isRecursiveCall) { - if (receiverIsSuper) failHere("it contains a recursive call targetting a supertype") + if (receiverIsSuper) failHere("it contains a recursive call targeting supertype " + receiver.tpe) else failHere(defaultReason) } else if (!matchesTypeArgs) failHere("it is called recursively with different type arguments") diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index e4b744dffc..7118436413 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -1423,6 +1423,8 @@ trait Namers extends MethodSynthesis { fail(LazyAndEarlyInit) if (sym.info.typeSymbol == FunctionClass(0) && sym.isValueParameter && sym.owner.isCaseClass) fail(ByNameParameter) + if (sym.isTrait && sym.isFinal) + checkNoConflict(ABSTRACT, FINAL) if (sym.isDeferred) { // Is this symbol type always allowed the deferred flag? diff --git a/src/library/scala/util/parsing/input/Positional.scala b/src/library/scala/util/parsing/input/Positional.scala index 2e9163d5ad..ff9d81d4e5 100644 --- a/src/library/scala/util/parsing/input/Positional.scala +++ b/src/library/scala/util/parsing/input/Positional.scala @@ -12,7 +12,6 @@ package scala.util.parsing.input * * @author Martin Odersky, Adriaan Moors */ -@deprecated("This class will be removed", "2.10.0") trait Positional { /** The source position of this object, initially set to undefined. */ diff --git a/test/files/neg/tailrec-2.check b/test/files/neg/tailrec-2.check index a918858773..d3432a7e76 100644 --- a/test/files/neg/tailrec-2.check +++ b/test/files/neg/tailrec-2.check @@ -1,4 +1,4 @@ -tailrec-2.scala:8: error: could not optimize @tailrec annotated method f: it contains a recursive call targetting a supertype +tailrec-2.scala:8: error: could not optimize @tailrec annotated method f: it contains a recursive call targeting supertype Super[A] @annotation.tailrec final def f[B >: A](mem: List[B]): List[B] = (null: Super[A]).f(mem) ^ tailrec-2.scala:9: error: @tailrec annotated method contains no recursive calls |