Skip to content

Commit 98ccb9f

Browse files
committed
Merge pull request scala#1564 from paulp/issue/441
Expanded unused warnings.
2 parents b5e3eaf + 477eee3 commit 98ccb9f

File tree

108 files changed

+452
-382
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+452
-382
lines changed

src/actors/scala/actors/Future.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ object Futures {
174174
* or timeout + `System.currentTimeMillis()` is negative.
175175
*/
176176
def awaitAll(timeout: Long, fts: Future[Any]*): List[Option[Any]] = {
177-
var resultsMap: scala.collection.mutable.Map[Int, Option[Any]] = new scala.collection.mutable.HashMap[Int, Option[Any]]
177+
val resultsMap: scala.collection.mutable.Map[Int, Option[Any]] = new scala.collection.mutable.HashMap[Int, Option[Any]]
178178

179179
var cnt = 0
180180
val mappedFts = fts.map(ft =>

src/compiler/scala/reflect/reify/codegen/GenTypes.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ trait GenTypes {
7474
if (reifyDebug) println("splicing " + tpe)
7575

7676
val tagFlavor = if (concrete) tpnme.TypeTag.toString else tpnme.WeakTypeTag.toString
77-
val key = (tagFlavor, tpe.typeSymbol)
7877
// if this fails, it might produce the dreaded "erroneous or inaccessible type" error
7978
// to find out the whereabouts of the error run scalac with -Ydebug
8079
if (reifyDebug) println("launching implicit search for %s.%s[%s]".format(universe, tagFlavor, tpe))

src/compiler/scala/reflect/reify/phases/Reshape.scala

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ trait Reshape {
4848
val Template(parents, self, body) = impl
4949
var body1 = trimAccessors(classDef, reshapeLazyVals(body))
5050
body1 = trimSyntheticCaseClassMembers(classDef, body1)
51-
var impl1 = Template(parents, self, body1).copyAttrs(impl)
51+
val impl1 = Template(parents, self, body1).copyAttrs(impl)
5252
ClassDef(mods, name, params, impl1).copyAttrs(classDef)
5353
case moduledef @ ModuleDef(mods, name, impl) =>
5454
val Template(parents, self, body) = impl
5555
var body1 = trimAccessors(moduledef, reshapeLazyVals(body))
5656
body1 = trimSyntheticCaseClassMembers(moduledef, body1)
57-
var impl1 = Template(parents, self, body1).copyAttrs(impl)
57+
val impl1 = Template(parents, self, body1).copyAttrs(impl)
5858
ModuleDef(mods, name, impl1).copyAttrs(moduledef)
5959
case template @ Template(parents, self, body) =>
6060
val discardedParents = parents collect { case tt: TypeTree => tt } filter isDiscarded
@@ -116,7 +116,6 @@ trait Reshape {
116116

117117
private def toPreTyperModifiers(mods: Modifiers, sym: Symbol) = {
118118
if (!sym.annotations.isEmpty) {
119-
val Modifiers(flags, privateWithin, annotations) = mods
120119
val postTyper = sym.annotations filter (_.original != EmptyTree)
121120
if (reifyDebug && !postTyper.isEmpty) println("reify symbol annotations for: " + sym)
122121
if (reifyDebug && !postTyper.isEmpty) println("originals are: " + sym.annotations)
@@ -252,7 +251,7 @@ trait Reshape {
252251
val DefDef(mods0, name0, _, _, tpt0, rhs0) = ddef
253252
val name1 = nme.dropLocalSuffix(name0)
254253
val Modifiers(flags0, privateWithin0, annotations0) = mods0
255-
var flags1 = (flags0 & GetterFlags) & ~(STABLE | ACCESSOR | METHOD)
254+
val flags1 = (flags0 & GetterFlags) & ~(STABLE | ACCESSOR | METHOD)
256255
val mods1 = Modifiers(flags1, privateWithin0, annotations0) setPositions mods0.positions
257256
val mods2 = toPreTyperModifiers(mods1, ddef.symbol)
258257
ValDef(mods2, name1, tpt0, extractRhs(rhs0))
@@ -267,7 +266,7 @@ trait Reshape {
267266

268267
def detectBeanAccessors(prefix: String): Unit = {
269268
if (defdef.name.startsWith(prefix)) {
270-
var name = defdef.name.toString.substring(prefix.length)
269+
val name = defdef.name.toString.substring(prefix.length)
271270
def uncapitalize(s: String) = if (s.length == 0) "" else { val chars = s.toCharArray; chars(0) = chars(0).toLower; new String(chars) }
272271
def findValDef(name: String) = (symdefs.values collect { case vdef: ValDef if nme.dropLocalSuffix(vdef.name).toString == name => vdef }).headOption
273272
val valdef = findValDef(name).orElse(findValDef(uncapitalize(name))).orNull
@@ -279,11 +278,11 @@ trait Reshape {
279278
detectBeanAccessors("is")
280279
});
281280

282-
var stats1 = stats flatMap {
281+
val stats1 = stats flatMap {
283282
case vdef @ ValDef(mods, name, tpt, rhs) if !mods.isLazy =>
284283
val mods1 = if (accessors.contains(vdef)) {
285284
val ddef = accessors(vdef)(0) // any accessor will do
286-
val Modifiers(flags, privateWithin, annotations) = mods
285+
val Modifiers(flags, _, annotations) = mods
287286
var flags1 = flags & ~LOCAL
288287
if (!ddef.symbol.isPrivate) flags1 = flags1 & ~PRIVATE
289288
val privateWithin1 = ddef.mods.privateWithin

src/compiler/scala/reflect/reify/utils/Extractors.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ trait Extractors {
187187
Literal(Constant(origin: String)))))
188188
if uref1.name == nme.UNIVERSE_SHORT && build1 == nme.build && newFreeTerm == nme.newFreeTerm &&
189189
uref2.name == nme.UNIVERSE_SHORT && build2 == nme.build && flagsFromBits == nme.flagsFromBits =>
190-
Some(uref1, name, reifyBinding(tree), flags, origin)
190+
Some((uref1, name, reifyBinding(tree), flags, origin))
191191
case _ =>
192192
None
193193
}
@@ -204,7 +204,7 @@ trait Extractors {
204204
Literal(Constant(origin: String)))))
205205
if uref1.name == nme.UNIVERSE_SHORT && build1 == nme.build && newFreeType == nme.newFreeType &&
206206
uref2.name == nme.UNIVERSE_SHORT && build2 == nme.build && flagsFromBits == nme.flagsFromBits =>
207-
Some(uref1, name, reifyBinding(tree), flags, origin)
207+
Some((uref1, name, reifyBinding(tree), flags, origin))
208208
case _ =>
209209
None
210210
}

src/compiler/scala/reflect/reify/utils/NodePrinters.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ trait NodePrinters {
2525
// Rolling a full-fledged, robust TreePrinter would be several times more code.
2626
// Also as of late we have tests that ensure that UX won't be broken by random changes to the reifier.
2727
val lines = (tree.toString.split(EOL) drop 1 dropRight 1).toList splitAt 2
28-
var (List(universe, mirror), reification) = lines
29-
reification = (for (line <- reification) yield {
28+
val (List(universe, mirror), reification0) = lines
29+
val reification = (for (line <- reification0) yield {
3030
var s = line substring 2
3131
s = s.replace(nme.UNIVERSE_PREFIX.toString, "")
3232
s = s.replace(".apply", "")

src/compiler/scala/reflect/reify/utils/SymbolTables.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ trait SymbolTables {
102102
newSymtab = newSymtab map { case ((sym, tree)) =>
103103
val ValDef(mods, primaryName, tpt, rhs) = tree
104104
val tree1 =
105-
if (!(newAliases contains (sym, primaryName))) {
105+
if (!(newAliases contains ((sym, primaryName)))) {
106106
val primaryName1 = newAliases.find(_._1 == sym).get._2
107107
ValDef(mods, primaryName1, tpt, rhs).copyAttrs(tree)
108108
} else tree
@@ -138,7 +138,7 @@ trait SymbolTables {
138138
var result = new SymbolTable(original = Some(encoded))
139139
encoded foreach (entry => (entry.attachments.get[ReifyBindingAttachment], entry.attachments.get[ReifyAliasAttachment]) match {
140140
case (Some(ReifyBindingAttachment(_)), _) => result += entry
141-
case (_, Some(ReifyAliasAttachment(sym, alias))) => result = new SymbolTable(result.symtab, result.aliases :+ (sym, alias))
141+
case (_, Some(ReifyAliasAttachment(sym, alias))) => result = new SymbolTable(result.symtab, result.aliases :+ ((sym, alias)))
142142
case _ => // do nothing, this is boilerplate that can easily be recreated by subsequent `result.encode`
143143
})
144144
result

src/compiler/scala/tools/ant/Pack200Task.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ class Pack200Task extends ScalaMatchingTask {
9999
private def getFileList: List[File] = {
100100
var files: List[File] = Nil
101101
val fs = getImplicitFileSet
102-
var ds = fs.getDirectoryScanner(getProject())
103-
var dir = fs.getDir(getProject())
102+
val ds = fs.getDirectoryScanner(getProject())
103+
val dir = fs.getDir(getProject())
104104
for (filename <- ds.getIncludedFiles()
105105
if filename.toLowerCase.endsWith(".jar")) {
106106
val file = new File(dir, filename)

src/compiler/scala/tools/nsc/Global.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,6 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
298298

299299
private val reader: SourceReader = {
300300
val defaultEncoding = Properties.sourceEncoding
301-
val defaultReader = Properties.sourceReader
302301

303302
def loadCharset(name: String) =
304303
try Some(Charset.forName(name))
@@ -1726,7 +1725,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
17261725
val printer = new icodes.TextPrinter(null, icodes.linearizer)
17271726
icodes.classes.values.foreach((cls) => {
17281727
val suffix = if (cls.symbol.hasModuleFlag) "$.icode" else ".icode"
1729-
var file = getFile(cls.symbol, suffix)
1728+
val file = getFile(cls.symbol, suffix)
17301729
// if (file.exists())
17311730
// file = new File(file.getParentFile(), file.getName() + "1")
17321731
try {

src/compiler/scala/tools/nsc/PhaseAssembly.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ trait PhaseAssembly {
5555
* node object does not exist, then create it.
5656
*/
5757
def getNodeByPhase(phs: SubComponent): Node = {
58-
var node: Node = getNodeByPhase(phs.phaseName)
58+
val node: Node = getNodeByPhase(phs.phaseName)
5959
node.phaseobj match {
6060
case None =>
6161
node.phaseobj = Some(List[SubComponent](phs))
@@ -75,7 +75,7 @@ trait PhaseAssembly {
7575
* list of the nodes
7676
*/
7777
def softConnectNodes(frm: Node, to: Node) {
78-
var e = new Edge(frm, to, false)
78+
val e = new Edge(frm, to, false)
7979
this.edges += e
8080

8181
frm.after += e
@@ -87,7 +87,7 @@ trait PhaseAssembly {
8787
* list of the nodes
8888
*/
8989
def hardConnectNodes(frm: Node, to: Node) {
90-
var e = new Edge(frm, to, true)
90+
val e = new Edge(frm, to, true)
9191
this.edges += e
9292

9393
frm.after += e
@@ -164,7 +164,7 @@ trait PhaseAssembly {
164164

165165
} else {
166166

167-
var promote = hl.to.before.filter(e => (!e.hard))
167+
val promote = hl.to.before.filter(e => (!e.hard))
168168
hl.to.before.clear
169169
sanity foreach (edge => hl.to.before += edge)
170170
for (edge <- promote) {
@@ -245,7 +245,7 @@ trait PhaseAssembly {
245245

246246
for (phs <- phsSet) {
247247

248-
var fromnode = graph.getNodeByPhase(phs)
248+
val fromnode = graph.getNodeByPhase(phs)
249249

250250
phs.runsRightAfter match {
251251
case None =>
@@ -306,7 +306,7 @@ trait PhaseAssembly {
306306
sbuf.append("\"" + node.allPhaseNames + "(" + node.level + ")" + "\" [color=\"#0000ff\"]\n")
307307
}
308308
sbuf.append("}\n")
309-
var out = new BufferedWriter(new FileWriter(filename))
309+
val out = new BufferedWriter(new FileWriter(filename))
310310
out.write(sbuf.toString)
311311
out.flush()
312312
out.close()

src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,6 @@ abstract class TreeBrowsers {
529529
* attributes */
530530
def symbolAttributes(t: Tree): String = {
531531
val s = t.symbol
532-
var att = ""
533532

534533
if ((s ne null) && (s != NoSymbol)) {
535534
var str = flagsToString(s.flags)

src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ trait MarkupParsers {
124124
val start = curOffset
125125
val key = xName
126126
xEQ
127-
val delim = ch
128127
val mid = curOffset
129128
val value: Tree = ch match {
130129
case '"' | '\'' =>
@@ -410,7 +409,7 @@ trait MarkupParsers {
410409
* | Name [S] '/' '>'
411410
*/
412411
def xPattern: Tree = {
413-
var start = curOffset
412+
val start = curOffset
414413
val qname = xName
415414
debugLastStartElement.push((start, qname))
416415
xSpaceOpt

src/compiler/scala/tools/nsc/ast/parser/Parsers.scala

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,7 @@ self =>
919919
)
920920

921921
def compoundTypeRest(t: Tree): Tree = {
922-
var ts = new ListBuffer[Tree] += t
922+
val ts = new ListBuffer[Tree] += t
923923
while (in.token == WITH) {
924924
in.nextToken()
925925
ts += annotType()
@@ -1267,7 +1267,7 @@ self =>
12671267
def expr(): Tree = expr(Local)
12681268

12691269
def expr(location: Int): Tree = {
1270-
var savedPlaceholderParams = placeholderParams
1270+
val savedPlaceholderParams = placeholderParams
12711271
placeholderParams = List()
12721272
var res = expr0(location)
12731273
if (!placeholderParams.isEmpty && !isWildcard(res)) {
@@ -1317,7 +1317,6 @@ self =>
13171317
parseTry
13181318
case WHILE =>
13191319
def parseWhile = {
1320-
val start = in.offset
13211320
atPos(in.skipToken()) {
13221321
val lname: Name = freshTermName(nme.WHILE_PREFIX)
13231322
val cond = condExpr()
@@ -1329,7 +1328,6 @@ self =>
13291328
parseWhile
13301329
case DO =>
13311330
def parseDo = {
1332-
val start = in.offset
13331331
atPos(in.skipToken()) {
13341332
val lname: Name = freshTermName(nme.DO_WHILE_PREFIX)
13351333
val body = expr()
@@ -1793,7 +1791,6 @@ self =>
17931791
* }}}
17941792
*/
17951793
def pattern2(): Tree = {
1796-
val nameOffset = in.offset
17971794
val p = pattern3()
17981795

17991796
if (in.token != AT) p
@@ -1906,7 +1903,7 @@ self =>
19061903
val start = in.offset
19071904
in.token match {
19081905
case IDENTIFIER | BACKQUOTED_IDENT | THIS =>
1909-
var t = stableId()
1906+
val t = stableId()
19101907
in.token match {
19111908
case INTLIT | LONGLIT | FLOATLIT | DOUBLELIT =>
19121909
t match {
@@ -2613,7 +2610,6 @@ self =>
26132610
in.nextToken()
26142611
newLinesOpt()
26152612
atPos(start, in.offset) {
2616-
val nameOffset = in.offset
26172613
val name = identForType()
26182614
// @M! a type alias as well as an abstract type may declare type parameters
26192615
val tparams = typeParamClauseOpt(name, null)
@@ -2890,7 +2886,6 @@ self =>
28902886
* }}}
28912887
*/
28922888
def packaging(start: Int): Tree = {
2893-
val nameOffset = in.offset
28942889
val pkg = pkgQualId()
28952890
val stats = inBracesOrNil(topStatSeq())
28962891
makePackaging(start, pkg, stats)
@@ -3100,7 +3095,6 @@ self =>
31003095
ts ++= topStatSeq()
31013096
}
31023097
} else {
3103-
val nameOffset = in.offset
31043098
in.flushDoc
31053099
val pkg = pkgQualId()
31063100

src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ abstract class TreeBuilder {
450450
def combine(gs: List[ValFrom]): ValFrom = (gs: @unchecked) match {
451451
case g :: Nil => g
452452
case ValFrom(pos1, pat1, rhs1) :: gs2 =>
453-
val ValFrom(pos2, pat2, rhs2) = combine(gs2)
453+
val ValFrom(_, pat2, rhs2) = combine(gs2)
454454
ValFrom(pos1, makeTuple(List(pat1, pat2), false), Apply(Select(rhs1, nme.zip), List(rhs2)))
455455
}
456456
makeForYield(List(combine(gs)), body)

src/compiler/scala/tools/nsc/backend/icode/GenICode.scala

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ abstract class GenICode extends SubComponent {
432432

433433
private def genPrimitiveOp(tree: Apply, ctx: Context, expectedType: TypeKind): (Context, TypeKind) = {
434434
val sym = tree.symbol
435-
val Apply(fun @ Select(receiver, _), args) = tree
435+
val Apply(fun @ Select(receiver, _), _) = tree
436436
val code = scalaPrimitives.getPrimitive(sym, receiver.tpe)
437437

438438
if (scalaPrimitives.isArithmeticOp(code))
@@ -543,9 +543,8 @@ abstract class GenICode extends SubComponent {
543543
// emits CIL_LOAD_ARRAY_ITEM_ADDRESS
544544
case Apply(fun, args) =>
545545
if (isPrimitive(fun.symbol)) {
546-
547546
val sym = tree.symbol
548-
val Apply(fun @ Select(receiver, _), args) = tree
547+
val Select(receiver, _) = fun
549548
val code = scalaPrimitives.getPrimitive(sym, receiver.tpe)
550549

551550
if (isArrayOp(code)) {
@@ -858,7 +857,7 @@ abstract class GenICode extends SubComponent {
858857
// we store this boxed value to a local, even if not really needed.
859858
// boxing optimization might use it, and dead code elimination will
860859
// take care of unnecessary stores
861-
var loc1 = ctx.makeLocal(tree.pos, expr.tpe, "boxed")
860+
val loc1 = ctx.makeLocal(tree.pos, expr.tpe, "boxed")
862861
ctx1.bb.emit(STORE_LOCAL(loc1))
863862
ctx1.bb.emit(LOAD_LOCAL(loc1))
864863
}
@@ -1104,7 +1103,7 @@ abstract class GenICode extends SubComponent {
11041103
case Match(selector, cases) =>
11051104
def genLoadMatch = {
11061105
debuglog("Generating SWITCH statement.");
1107-
var ctx1 = genLoad(selector, ctx, INT) // TODO: Java 7 allows strings in switches (so, don't assume INT and don't convert the literals using intValue)
1106+
val ctx1 = genLoad(selector, ctx, INT) // TODO: Java 7 allows strings in switches (so, don't assume INT and don't convert the literals using intValue)
11081107
val afterCtx = ctx1.newBlock
11091108
var caseCtx: Context = null
11101109
generatedType = toTypeKind(tree.tpe)
@@ -2116,7 +2115,7 @@ abstract class GenICode extends SubComponent {
21162115
} else ctx
21172116

21182117

2119-
val finalizerExh = if (finalizer != EmptyTree) Some({
2118+
if (finalizer != EmptyTree) {
21202119
val exh = outerCtx.newExceptionHandler(NoSymbol, toTypeKind(finalizer.tpe), finalizer.pos) // finalizer covers exception handlers
21212120
this.addActiveHandler(exh) // .. and body aswell
21222121
val ctx = finalizerCtx.enterExceptionHandler(exh)
@@ -2129,21 +2128,20 @@ abstract class GenICode extends SubComponent {
21292128
ctx1.bb.enterIgnoreMode;
21302129
ctx1.bb.close
21312130
finalizerCtx.endHandler()
2132-
exh
2133-
}) else None
2134-
2135-
val exhs = handlers.map { case (sym, kind, handler) => // def genWildcardHandler(sym: Symbol): (Symbol, TypeKind, Context => Context) =
2136-
val exh = this.newExceptionHandler(sym, kind, tree.pos)
2137-
var ctx1 = outerCtx.enterExceptionHandler(exh)
2138-
ctx1.addFinalizer(finalizer, finalizerCtx)
2139-
loadException(ctx1, exh, tree.pos)
2140-
ctx1 = handler(ctx1)
2141-
// emit finalizer
2142-
val ctx2 = emitFinalizer(ctx1)
2143-
ctx2.bb.closeWith(JUMP(afterCtx.bb))
2144-
outerCtx.endHandler()
2145-
exh
2146-
}
2131+
}
2132+
2133+
for ((sym, kind, handler) <- handlers) {
2134+
val exh = this.newExceptionHandler(sym, kind, tree.pos)
2135+
var ctx1 = outerCtx.enterExceptionHandler(exh)
2136+
ctx1.addFinalizer(finalizer, finalizerCtx)
2137+
loadException(ctx1, exh, tree.pos)
2138+
ctx1 = handler(ctx1)
2139+
// emit finalizer
2140+
val ctx2 = emitFinalizer(ctx1)
2141+
ctx2.bb.closeWith(JUMP(afterCtx.bb))
2142+
outerCtx.endHandler()
2143+
}
2144+
21472145
val bodyCtx = this.newBlock
21482146
if (finalizer != EmptyTree)
21492147
bodyCtx.addFinalizer(finalizer, finalizerCtx)

0 commit comments

Comments
 (0)