From 8182349189250b0da92e566e11e5a59ac22ca805 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sat, 30 Apr 2011 20:01:48 +0000 Subject: A few minor cleanups involving logging messages... A few minor cleanups involving logging messages, assertion messages, compiler warnings, and other innocuous matters. No review. --- src/compiler/scala/tools/ant/FastScalac.scala | 2 +- src/compiler/scala/tools/nsc/Global.scala | 2 +- src/compiler/scala/tools/nsc/ast/TreePrinters.scala | 4 ++-- src/compiler/scala/tools/nsc/backend/icode/GenICode.scala | 2 +- src/compiler/scala/tools/nsc/interpreter/Power.scala | 2 +- .../scala/tools/nsc/matching/ParallelMatching.scala | 13 +++++++------ src/compiler/scala/tools/nsc/matching/Patterns.scala | 10 ++++++++-- src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala | 5 ++++- src/compiler/scala/tools/nsc/typechecker/Namers.scala | 10 ++++++++-- 9 files changed, 33 insertions(+), 17 deletions(-) diff --git a/src/compiler/scala/tools/ant/FastScalac.scala b/src/compiler/scala/tools/ant/FastScalac.scala index 403d9cc117..a2a7496824 100644 --- a/src/compiler/scala/tools/ant/FastScalac.scala +++ b/src/compiler/scala/tools/ant/FastScalac.scala @@ -103,7 +103,7 @@ class FastScalac extends Scalac { val args = (cmdOptions ::: (sourceFiles map (_.toString))).toArray try { - if (scala.tools.nsc.CompileClient.process(args) != 0 && failonerror) + if (scala.tools.nsc.CompileClient.process(args) && failonerror) buildError("Compile failed; see the compiler error output for details.") } catch { diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index b8f9fea3ef..bdf9718e2a 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -1226,6 +1226,6 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable def forScaladoc = onlyPresentation def createJavadoc = false - @deprecated("Use forInteractive or forScaladoc, depending on what you're after") + @deprecated("Use forInteractive or forScaladoc, depending on what you're after", "2.9.0") def onlyPresentation = false } diff --git a/src/compiler/scala/tools/nsc/ast/TreePrinters.scala b/src/compiler/scala/tools/nsc/ast/TreePrinters.scala index ef2906de06..96f4355590 100644 --- a/src/compiler/scala/tools/nsc/ast/TreePrinters.scala +++ b/src/compiler/scala/tools/nsc/ast/TreePrinters.scala @@ -546,7 +546,7 @@ trait TreePrinters { trees: SymbolTable => } val List(thenStmts, elseStmts) = List(thenp, elsep) map allStatements - print("if ("); print(cond); print(")") + print("if ("); print(cond); print(") ") thenStmts match { case List(x: If) => ifIndented(x) @@ -555,7 +555,7 @@ trait TreePrinters { trees: SymbolTable => } if (elseStmts.nonEmpty) { - print("else") + print(" else") indent ; println() elseStmts match { case List(x) => printRaw(x) diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala index 8c7997157e..dd85541780 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala @@ -1147,7 +1147,7 @@ abstract class GenICode extends SubComponent { "Can't convert from UNIT to " + to + " at: " + pos) } assert(!from.isReferenceType && !to.isReferenceType, - "type error: can't convert from " + from + " to " + to +" in unit " + unit.source) + "type error: can't convert from " + from + " to " + to +" in unit " + unit.source + " at " + pos) ctx.bb.emit(CALL_PRIMITIVE(Conversion(from, to)), pos) } diff --git a/src/compiler/scala/tools/nsc/interpreter/Power.scala b/src/compiler/scala/tools/nsc/interpreter/Power.scala index 14d6613abd..8e546519e5 100644 --- a/src/compiler/scala/tools/nsc/interpreter/Power.scala +++ b/src/compiler/scala/tools/nsc/interpreter/Power.scala @@ -134,7 +134,7 @@ abstract class Power[G <: Global]( def init = customInit getOrElse """ |import scala.tools.nsc._ |import scala.collection.JavaConverters._ - |import global._ + |import global.{ error => _, _ } |import power.Implicits._ """.stripMargin diff --git a/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala b/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala index fb617908c7..e198656eb5 100644 --- a/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala +++ b/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala @@ -171,8 +171,7 @@ trait ParallelMatching extends ast.TreeDSL def size = ps.length def headType = head.necessaryType - def isCaseHead = head.isCaseClass - private val dummyCount = if (isCaseHead) headType.typeSymbol.caseFieldAccessors.length else 0 + private val dummyCount = if (head.isCaseClass) headType.typeSymbol.caseFieldAccessors.length else 0 def dummies = emptyPatterns(dummyCount) def apply(i: Int): Pattern = ps(i) @@ -416,9 +415,6 @@ trait ParallelMatching extends ast.TreeDSL private def pivotLen = pivot.nonStarLength private def seqDummies = emptyPatterns(pivot.elems.length + 1) - // one pattern var per sequence element up to elemCount, and one more for the rest of the sequence - lazy val pvs = scrut createSequenceVars pivotLen - // Should the given pattern join the expanded pivot in the success matrix? If so, // this partial function will be defined for the pattern, and the result of the apply // is the expanded sequence of new patterns. @@ -496,7 +492,12 @@ trait ParallelMatching extends ast.TreeDSL nullSafe(compareFn, FALSE)(scrut.id) // condition(head.tpe, scrut.id, head.boundVariables.nonEmpty) } - lazy val success = squeezedBlock(pvs map (_.valDef), remake(successRows, pvs, hasStar).toTree) + lazy val success = { + // one pattern var per sequence element up to elemCount, and one more for the rest of the sequence + lazy val pvs = scrut createSequenceVars pivotLen + + squeezedBlock(pvs map (_.valDef), remake(successRows, pvs, hasStar).toTree) + } lazy val failure = remake(failRows).toTree final def tree(): Tree = codegen diff --git a/src/compiler/scala/tools/nsc/matching/Patterns.scala b/src/compiler/scala/tools/nsc/matching/Patterns.scala index e0734e7f2e..3ea1b1cdb2 100644 --- a/src/compiler/scala/tools/nsc/matching/Patterns.scala +++ b/src/compiler/scala/tools/nsc/matching/Patterns.scala @@ -68,13 +68,14 @@ trait Patterns extends ast.TreeDSL { // 8.1.2 case class TypedPattern(tree: Typed) extends Pattern { private val Typed(expr, tpt) = tree + private lazy val exprPat = Pattern(expr) override def subpatternsForVars: List[Pattern] = List(Pattern(expr)) override def simplify(pv: PatternVar) = Pattern(expr) match { case ExtractorPattern(ua) if pv.sym.tpe <:< tpt.tpe => this rebindTo expr case _ => this } - override def description = "Typ(%s: %s)".format(Pattern(expr), tpt) + override def description = "%s: %s".format(exprPat.boundNameString, tpt) } // 8.1.3 @@ -143,7 +144,7 @@ trait Patterns extends ast.TreeDSL { // 8.1.5 case class ConstructorPattern(tree: Apply) extends ApplyPattern with NamePattern { - require(fn.isType && this.isCaseClass) + require(fn.isType && this.isCaseClass, "tree: " + tree + " fn: " + fn) def name = tpe.typeSymbol.name def cleanName = tpe.typeSymbol.decodedName def hasPrefix = tpe.prefix.prefixString != "" @@ -454,6 +455,11 @@ trait Patterns extends ast.TreeDSL { tree setType tpe this } + def boundName: Option[Name] = boundTree match { + case Bind(name, _) => Some(name) + case _ => None + } + def boundNameString = "" + (boundName getOrElse "_") def equalsCheck = tracing("equalsCheck")( diff --git a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala index 65ad711845..79f13cc6d3 100644 --- a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala +++ b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala @@ -25,6 +25,7 @@ abstract class ExplicitOuter extends InfoTransform import global._ import definitions._ import CODE._ + import Debug.TRACE /** The following flags may be set by this phase: */ override def phaseNewFlags: Long = notPRIVATE | notPROTECTED | lateFINAL @@ -70,7 +71,9 @@ abstract class ExplicitOuter extends InfoTransform class RemoveBindingsTransformer(toRemove: Set[Symbol]) extends Transformer { override def transform(tree: Tree) = tree match { - case Bind(_, body) if toRemove(tree.symbol) => super.transform(body) + case Bind(_, body) if toRemove(tree.symbol) => + TRACE("Dropping unused binding: " + tree.symbol) + super.transform(body) case _ => super.transform(tree) } } diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index b0cfa6a559..8f20f2a120 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -1239,8 +1239,14 @@ trait Namers { self: Analyzer => case ImportSelector(from, _, to, _) :: rest => if (from != nme.WILDCARD && base != ErrorType) { isValidSelector(from) { - if (currentRun.compileSourceFor(expr, from)) - return typeSig(tree) + if (currentRun.compileSourceFor(expr, from)) { + // XXX This used to be "return typeSig(tree)" but since this method + // returns Unit, that is deceptive at best. Just in case it is side-effecting + // somehow, I left the call in before the return; if you know it is + // not side effecting, please delete the call. + typeSig(tree) + return + } def notMember = context.error(tree.pos, from.decode + " is not a member of " + expr) // for Java code importing Scala objects -- cgit v1.2.3