Permalink
Browse files

Eliminate a bunch of -Xlint warnings.

Mostly unused private code, unused imports, and points where
an extra pair of parentheses is necessary for scalac to have
confidence in our intentions.
  • Loading branch information...
1 parent 9fed30c commit fc5e5581ec2eb91d22cbc8a2f19729c7c9a87254 @paulp paulp committed Mar 12, 2013
Showing with 113 additions and 162 deletions.
  1. +0 −2 src/compiler/scala/tools/nsc/Global.scala
  2. +0 −2 src/compiler/scala/tools/nsc/ast/Positions.scala
  3. +2 −3 src/compiler/scala/tools/nsc/ast/Trees.scala
  4. +8 −8 src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
  5. +5 −5 src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala
  6. +1 −1 src/compiler/scala/tools/nsc/backend/JavaPlatform.scala
  7. +21 −21 src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
  8. +1 −1 src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala
  9. +0 −1 src/compiler/scala/tools/nsc/backend/jvm/GenJVMASM.scala
  10. +2 −2 src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala
  11. +3 −5 src/compiler/scala/tools/nsc/settings/MutableSettings.scala
  12. +1 −1 src/compiler/scala/tools/nsc/transform/AddInterfaces.scala
  13. +1 −1 src/compiler/scala/tools/nsc/transform/Constructors.scala
  14. +0 −1 src/compiler/scala/tools/nsc/transform/Erasure.scala
  15. +1 −1 src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
  16. +1 −3 src/compiler/scala/tools/nsc/transform/UnCurry.scala
  17. +5 −6 src/compiler/scala/tools/nsc/transform/patmat/Logic.scala
  18. +10 −14 src/compiler/scala/tools/nsc/transform/patmat/MatchAnalysis.scala
  19. +3 −7 src/compiler/scala/tools/nsc/transform/patmat/MatchCodeGen.scala
  20. +3 −10 src/compiler/scala/tools/nsc/transform/patmat/MatchOptimization.scala
  21. +1 −1 src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala
  22. +15 −21 src/compiler/scala/tools/nsc/transform/patmat/MatchTreeMaking.scala
  23. +0 −7 src/compiler/scala/tools/nsc/transform/patmat/Solving.scala
  24. +0 −1 src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala
  25. +10 −10 src/compiler/scala/tools/nsc/typechecker/Contexts.scala
  26. +1 −1 src/compiler/scala/tools/nsc/typechecker/Duplicators.scala
  27. +1 −1 src/compiler/scala/tools/nsc/typechecker/Implicits.scala
  28. +1 −1 src/compiler/scala/tools/nsc/typechecker/Infer.scala
  29. +2 −2 src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
  30. +0 −1 src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala
  31. +4 −5 src/compiler/scala/tools/nsc/typechecker/Typers.scala
  32. +1 −1 src/compiler/scala/tools/reflect/FastTrack.scala
  33. +3 −3 src/compiler/scala/tools/reflect/ToolBoxFactory.scala
  34. +1 −1 src/interactive/scala/tools/nsc/interactive/CompilerControl.scala
  35. +2 −2 src/reflect/scala/reflect/api/Trees.scala
  36. +1 −1 src/reflect/scala/reflect/internal/TreeGen.scala
  37. +0 −1 src/repl/scala/tools/nsc/interpreter/ExprTyper.scala
  38. +0 −1 src/repl/scala/tools/nsc/interpreter/MemberHandlers.scala
  39. +0 −1 src/scaladoc/scala/tools/nsc/doc/base/CommentFactoryBase.scala
  40. +0 −2 src/scaladoc/scala/tools/nsc/doc/base/LinkTo.scala
  41. +1 −1 src/scaladoc/scala/tools/nsc/doc/base/MemberLookupBase.scala
  42. +0 −1 src/scaladoc/scala/tools/nsc/doc/model/ModelFactory.scala
  43. +1 −1 src/scaladoc/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala
@@ -795,8 +795,6 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
} reverse
}
- private def numberedPhase(ph: Phase) = "%2d/%s".format(ph.id, ph.name)
-
// ------------ Invalidations ---------------------------------
/** Is given package class a system package class that cannot be invalidated?
@@ -1,8 +1,6 @@
package scala.tools.nsc
package ast
-import scala.reflect.internal.util.{ SourceFile, OffsetPosition }
-
trait Positions extends scala.reflect.internal.Positions {
self: Global =>
@@ -100,12 +100,11 @@ trait Trees extends scala.reflect.internal.Trees { self: Global =>
if (body forall treeInfo.isInterfaceMember) List()
else List(
atPos(wrappingPos(superPos, lvdefs)) (
- DefDef(NoMods, nme.MIXIN_CONSTRUCTOR, List(), ListOfNil, TypeTree(), Block(lvdefs, Literal(Constant())))))
+ DefDef(NoMods, nme.MIXIN_CONSTRUCTOR, List(), ListOfNil, TypeTree(), Block(lvdefs, Literal(Constant(()))))))
} else {
// convert (implicit ... ) to ()(implicit ... ) if its the only parameter section
if (vparamss1.isEmpty || !vparamss1.head.isEmpty && vparamss1.head.head.mods.isImplicit)
vparamss1 = List() :: vparamss1
- val superRef: Tree = atPos(superPos)(gen.mkSuperInitCall)
val superCall = pendingSuperCall // we can't know in advance which of the parents will end up as a superclass
// this requires knowing which of the parents is a type macro and which is not
// and that's something that cannot be found out before typer
@@ -116,7 +115,7 @@ trait Trees extends scala.reflect.internal.Trees { self: Global =>
// TODO: previously this was `wrappingPos(superPos, lvdefs ::: argss.flatten)`
// is it going to be a problem that we can no longer include the `argss`?
atPos(wrappingPos(superPos, lvdefs)) (
- DefDef(constrMods, nme.CONSTRUCTOR, List(), vparamss1, TypeTree(), Block(lvdefs ::: List(superCall), Literal(Constant())))))
+ DefDef(constrMods, nme.CONSTRUCTOR, List(), vparamss1, TypeTree(), Block(lvdefs ::: List(superCall), Literal(Constant(()))))))
}
}
constrs foreach (ensureNonOverlapping(_, parents ::: gvdefs, focus=false))
@@ -57,7 +57,7 @@ trait ParsersCommon extends ScannersCommon {
if (in.token == LPAREN) inParens(body)
else { accept(LPAREN) ; alt }
- @inline final def inParensOrUnit[T](body: => Tree): Tree = inParensOrError(body, Literal(Constant()))
+ @inline final def inParensOrUnit[T](body: => Tree): Tree = inParensOrError(body, Literal(Constant(())))
@inline final def inParensOrNil[T](body: => List[T]): List[T] = inParensOrError(body, Nil)
@inline final def inBraces[T](body: => T): T = {
@@ -71,7 +71,7 @@ trait ParsersCommon extends ScannersCommon {
else { accept(LBRACE) ; alt }
@inline final def inBracesOrNil[T](body: => List[T]): List[T] = inBracesOrError(body, Nil)
- @inline final def inBracesOrUnit[T](body: => Tree): Tree = inBracesOrError(body, Literal(Constant()))
+ @inline final def inBracesOrUnit[T](body: => Tree): Tree = inBracesOrError(body, Literal(Constant(())))
@inline final def dropAnyBraces[T](body: => T): T =
if (in.token == LBRACE) inBraces(body)
else body
@@ -1249,7 +1249,7 @@ self =>
newLinesOpt()
val thenp = expr()
val elsep = if (in.token == ELSE) { in.nextToken(); expr() }
- else Literal(Constant())
+ else Literal(Constant(()))
If(cond, thenp, elsep)
}
parseIf
@@ -1323,7 +1323,7 @@ self =>
case RETURN =>
def parseReturn =
atPos(in.skipToken()) {
- Return(if (isExprIntro) expr() else Literal(Constant()))
+ Return(if (isExprIntro) expr() else Literal(Constant(())))
}
parseReturn
case THROW =>
@@ -2524,7 +2524,7 @@ self =>
*/
def constrExpr(vparamss: List[List[ValDef]]): Tree =
if (in.token == LBRACE) constrBlock(vparamss)
- else Block(List(selfInvocation(vparamss)), Literal(Constant()))
+ else Block(List(selfInvocation(vparamss)), Literal(Constant(())))
/** {{{
* SelfInvocation ::= this ArgumentExprs {ArgumentExprs}
@@ -2554,7 +2554,7 @@ self =>
else Nil
}
accept(RBRACE)
- Block(stats, Literal(Constant()))
+ Block(stats, Literal(Constant(())))
}
/** {{{
@@ -2760,7 +2760,7 @@ self =>
def anyvalConstructor() = (
// Not a well-formed constructor, has to be finished later - see note
// regarding AnyVal constructor in AddInterfaces.
- DefDef(NoMods, nme.CONSTRUCTOR, Nil, ListOfNil, TypeTree(), Block(Nil, Literal(Constant())))
+ DefDef(NoMods, nme.CONSTRUCTOR, Nil, ListOfNil, TypeTree(), Block(Nil, Literal(Constant(()))))
)
val tstart0 = if (body.isEmpty && in.lastOffset < tstart) in.lastOffset else tstart
@@ -2986,7 +2986,7 @@ self =>
else List(tmplDef(pos, mods))
in.token match {
- case RBRACE | CASE => defs :+ (Literal(Constant()) setPos o2p(in.offset))
+ case RBRACE | CASE => defs :+ (Literal(Constant(())) setPos o2p(in.offset))
case _ => defs
}
}
@@ -131,7 +131,7 @@ abstract class TreeBuilder {
}
def makeTupleTerm(trees: List[Tree], flattenUnary: Boolean): Tree = trees match {
- case Nil => Literal(Constant())
+ case Nil => Literal(Constant(()))
case List(tree) if flattenUnary => tree
case _ => makeTuple(trees, isType = false)
}
@@ -250,21 +250,21 @@ abstract class TreeBuilder {
/** Create tree representing a while loop */
def makeWhile(lname: TermName, cond: Tree, body: Tree): Tree = {
val continu = atPos(o2p(body.pos pointOrElse wrappingPos(List(cond, body)).pos.endOrPoint)) { Apply(Ident(lname), Nil) }
- val rhs = If(cond, Block(List(body), continu), Literal(Constant()))
+ val rhs = If(cond, Block(List(body), continu), Literal(Constant(())))
LabelDef(lname, Nil, rhs)
}
/** Create tree representing a do-while loop */
def makeDoWhile(lname: TermName, body: Tree, cond: Tree): Tree = {
val continu = Apply(Ident(lname), Nil)
- val rhs = Block(List(body), If(cond, continu, Literal(Constant())))
+ val rhs = Block(List(body), If(cond, continu, Literal(Constant(()))))
LabelDef(lname, Nil, rhs)
}
/** Create block of statements `stats` */
def makeBlock(stats: List[Tree]): Tree =
- if (stats.isEmpty) Literal(Constant())
- else if (!stats.last.isTerm) Block(stats, Literal(Constant()))
+ if (stats.isEmpty) Literal(Constant(()))
+ else if (!stats.last.isTerm) Block(stats, Literal(Constant(())))
else if (stats.length == 1) stats.head
else Block(stats.init, stats.last)
@@ -7,7 +7,7 @@ package scala.tools.nsc
package backend
import io.AbstractFile
-import util.{ClassPath,JavaClassPath,MergedClassPath,DeltaClassPath}
+import util.{ClassPath,MergedClassPath,DeltaClassPath}
import scala.tools.util.PathResolver
trait JavaPlatform extends Platform {
@@ -276,8 +276,8 @@ abstract class GenICode extends SubComponent {
generatedType = elem
ctx1.bb.emit(LOAD_ARRAY_ITEM(elementType), tree.pos)
// it's tempting to just drop array loads of type Null instead
- // of adapting them but array accesses can cause
- // ArrayIndexOutOfBounds so we can't. Besides, Array[Null]
+ // of adapting them but array accesses can cause
+ // ArrayIndexOutOfBounds so we can't. Besides, Array[Null]
// probably isn't common enough to figure out an optimization
adaptNullRef(generatedType, expectedType, ctx1, tree.pos)
}
@@ -479,11 +479,11 @@ abstract class GenICode extends SubComponent {
val resCtx: Context = tree match {
case LabelDef(name, params, rhs) =>
def genLoadLabelDef = {
- val ctx1 = ctx.newBlock() // note: we cannot kill ctx1 if ctx is in ignore mode because
+ val ctx1 = ctx.newBlock() // note: we cannot kill ctx1 if ctx is in ignore mode because
// label defs can be the target of jumps from other locations.
// that means label defs can lead to unreachable code without
// proper reachability analysis
-
+
if (nme.isLoopHeaderLabel(name))
ctx1.bb.loopHeader = true
@@ -1018,7 +1018,7 @@ abstract class GenICode extends SubComponent {
resCtx
}
-
+
/**
* If we have a method call, field load, or array element load of type Null then
* we need to convince the JVM that we have a null value because in Scala
@@ -1030,9 +1030,9 @@ abstract class GenICode extends SubComponent {
*/
private def adaptNullRef(from: TypeKind, to: TypeKind, ctx: Context, pos: Position) {
log(s"GenICode#adaptNullRef($from, $to, $ctx, $pos)")
-
+
// Don't need to adapt null to unit because we'll just drop it anyway. Don't
- // need to adapt to Object or AnyRef because the JVM is happy with
+ // need to adapt to Object or AnyRef because the JVM is happy with
// upcasting Null to them.
// We do have to adapt from NullReference to NullReference because we could be storing
// this value into a local of type Null and we want the JVM to see that it's
@@ -1066,12 +1066,12 @@ abstract class GenICode extends SubComponent {
ctx.bb.enterIgnoreMode()
case _ if from isAssignabledTo to =>
()
- case (_, UNIT) =>
+ case (_, UNIT) =>
ctx.bb.emit(DROP(from), pos)
// otherwise we'd better be doing a primtive -> primitive coercion or there's a problem
- case _ if !from.isRefOrArrayType && !to.isRefOrArrayType =>
+ case _ if !from.isRefOrArrayType && !to.isRefOrArrayType =>
coerce(from, to)
- case _ =>
+ case _ =>
assert(false, s"Can't convert from $from to $to in unit ${unit.source} at $pos")
}
}
@@ -1356,10 +1356,10 @@ abstract class GenICode extends SubComponent {
ctx: Context,
thenCtx: Context,
elseCtx: Context): Boolean =
- {
+ {
/**
* Generate the de-sugared comparison mechanism that will underly an '=='
- *
+ *
* @param l left-hand side of the '=='
* @param r right-hand side of the '=='
* @param code the comparison operator to use
@@ -1961,34 +1961,34 @@ abstract class GenICode extends SubComponent {
* }), (AnotherExceptionClass,
* ctx => {...
* } ))`
- *
+ *
* The resulting structure will look something like
- *
+ *
* outer:
* // this 'useless' jump will be removed later,
* // for now it separates the try body's blocks from previous
* // code since the try body needs its own exception handlers
* JUMP body
- *
+ *
* body:
* [ try body ]
* JUMP normalExit
- *
+ *
* catch[i]:
* [ handler[i] body ]
* JUMP normalExit
- *
+ *
* catchAll:
* STORE exception
* [ finally body ]
* THROW exception
- *
+ *
* normalExit:
* [ finally body ]
- *
+ *
* each catch[i] will cover body. catchAll will cover both body and each catch[i]
* Additional finally copies are created on the emission of every RETURN in the try body and exception handlers.
- *
+ *
* This could result in unreachable code which has to be cleaned up later, e.g. if the try and all the exception
* handlers always end in RETURN then there will be no "normal" flow out of the try/catch/finally.
* Later reachability analysis will remove unreacahble code.
@@ -2047,7 +2047,7 @@ abstract class GenICode extends SubComponent {
exhEndCtx.bb.enterIgnoreMode()
finalizerCtx.endHandler()
}
-
+
// Generate each exception handler
for ((sym, kind, handler) <- handlers) {
val exh = this.newExceptionHandler(sym, tree.pos)
@@ -2634,7 +2634,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM {
if(from == to) { return }
// the only conversion involving BOOL that is allowed is (BOOL -> BOOL)
- assert(from != BOOL && to != BOOL, "inconvertible types : $from -> $to")
+ assert(from != BOOL && to != BOOL, s"inconvertible types : $from -> $to")
if(from.isIntSizedType) { // BYTE, CHAR, SHORT, and INT. (we're done with BOOL already)
@@ -67,7 +67,6 @@ trait GenJVMASM {
// Before erasure so we can identify generic mains.
enteringErasure {
val companion = sym.linkedClassOfClass
- val companionMain = companion.tpe.member(nme.main)
if (hasJavaMainMethod(companion))
failNoForwarder("companion contains its own main method")
@@ -218,7 +218,7 @@ abstract class DeadCodeElimination extends SubComponent {
// worklist so we also mark their reaching defs as useful - see SI-7060
if (!useful(bb)(idx)) {
useful(bb) += idx
- dropOf.get(bb, idx) foreach {
+ dropOf.get((bb, idx)) foreach {
for ((bb1, idx1) <- _) {
/*
* SI-7060: A drop that we now mark as useful can be reached via several paths,
@@ -346,7 +346,7 @@ abstract class DeadCodeElimination extends SubComponent {
if (useful(bb)(idx)) {
debuglog(" * " + i + " is useful")
bb.emit(i, i.pos)
- compensations.get(bb, idx) match {
+ compensations.get((bb, idx)) match {
case Some(is) => is foreach bb.emit
case None => ()
}
@@ -486,23 +486,21 @@ class MutableSettings(val errorFn: String => Unit)
descr: String,
default: ScalaVersion)
extends Setting(name, descr) {
- import ScalaVersion._
-
type T = ScalaVersion
protected var v: T = NoScalaVersion
override def tryToSet(args: List[String]) = {
value = default
Some(args)
}
-
+
override def tryToSetColon(args: List[String]) = args match {
case Nil => value = default; Some(Nil)
case x :: xs => value = ScalaVersion(x, errorFn) ; Some(xs)
}
-
+
override def tryToSetFromPropertyValue(s: String) = tryToSet(List(s))
-
+
def unparse: List[String] = if (value == NoScalaVersion) Nil else List(s"${name}:${value.unparse}")
withHelpSyntax(s"${name}:<${arg}>")
@@ -276,7 +276,7 @@ abstract class AddInterfaces extends InfoTransform { self: Erasure =>
*/
private def addMixinConstructorDef(clazz: Symbol, stats: List[Tree]): List[Tree] =
if (treeInfo.firstConstructor(stats) != EmptyTree) stats
- else DefDef(clazz.primaryConstructor, Block(List(), Literal(Constant()))) :: stats
+ else DefDef(clazz.primaryConstructor, Block(List(), Literal(Constant(())))) :: stats
private def implTemplate(clazz: Symbol, templ: Template): Template = atPos(templ.pos) {
val templ1 = (
@@ -366,7 +366,7 @@ abstract class Constructors extends Transform with ast.TreeDSL {
CODE.NOT (
Apply(gen.mkAttributedRef(specializedFlag), List())),
List()),
- Block(stats, Literal(Constant())),
+ Block(stats, Literal(Constant(()))),
EmptyTree)
List(localTyper.typed(tree))
@@ -21,7 +21,6 @@ abstract class Erasure extends AddInterfaces
import global._
import definitions._
import CODE._
- import treeInfo._
val phaseName: String = "erasure"
@@ -1527,7 +1527,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
if (symbol.isConstructor) {
val t = atOwner(symbol)(forwardCtorCall(tree.pos, gen.mkSuperInitCall, vparamss, symbol.owner))
if (symbol.isPrimaryConstructor)
- localTyper.typedPos(symbol.pos)(deriveDefDef(tree)(_ => Block(List(t), Literal(Constant()))))
+ localTyper.typedPos(symbol.pos)(deriveDefDef(tree)(_ => Block(List(t), Literal(Constant(())))))
else // duplicate the original constructor
reportError(duplicateBody(ddef, info(symbol).target))(_ => ddef)
}
@@ -550,8 +550,6 @@ abstract class UnCurry extends InfoTransform
false
}
- def isDefaultCatch(cdef: CaseDef) = isThrowable(cdef.pat) && cdef.guard.isEmpty
-
tree match {
/* Some uncurry post transformations add members to templates.
*
@@ -701,7 +699,7 @@ abstract class UnCurry extends InfoTransform
// update the type of the method after uncurry.
dd.symbol updateInfo {
val GenPolyType(tparams, tp) = dd.symbol.info
- logResult("erased dependent param types for ${dd.symbol.info}") {
+ logResult(s"erased dependent param types for ${dd.symbol.info}") {
GenPolyType(tparams, MethodType(allParams map (_.symbol), tp.finalResultType))
}
}
Oops, something went wrong.

0 comments on commit fc5e558

Please sign in to comment.