diff options
author | Paul Phillips <paulp@improving.org> | 2012-11-03 06:29:38 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-11-03 07:01:15 -0700 |
commit | 9c09c170998f74fba03990977b285e3121db32a6 (patch) | |
tree | ee12a85233e6927e5ec3698fc83f26fb46ad43e6 | |
parent | d3da3ef83293c0e174e07aba643b3a1f46c110c5 (diff) | |
download | scala-9c09c170998f74fba03990977b285e3121db32a6.tar.gz scala-9c09c170998f74fba03990977b285e3121db32a6.tar.bz2 scala-9c09c170998f74fba03990977b285e3121db32a6.zip |
Removing unused locals and making vars into vals.
According to "git diff" the difference from master to this
commit includes:
Minus: 112 vals, 135 vars
Plus: 165 vals, 2 vars
Assuming all the removed ones were vals, which is true from 10K feet,
it suggests I removed 80 unused vals and turned 133 vars into vals.
There are a few other -Xlint driven improvements bundled with this,
like putting double-parentheses around Some((x, y)) so it doesn't
trigger the "adapting argument list" warning.
106 files changed, 278 insertions, 355 deletions
diff --git a/src/actors/scala/actors/Future.scala b/src/actors/scala/actors/Future.scala index fb7bb488a2..3269174afe 100644 --- a/src/actors/scala/actors/Future.scala +++ b/src/actors/scala/actors/Future.scala @@ -174,7 +174,7 @@ object Futures { * or timeout + `System.currentTimeMillis()` is negative. */ def awaitAll(timeout: Long, fts: Future[Any]*): List[Option[Any]] = { - var resultsMap: scala.collection.mutable.Map[Int, Option[Any]] = new scala.collection.mutable.HashMap[Int, Option[Any]] + val resultsMap: scala.collection.mutable.Map[Int, Option[Any]] = new scala.collection.mutable.HashMap[Int, Option[Any]] var cnt = 0 val mappedFts = fts.map(ft => diff --git a/src/compiler/scala/reflect/reify/codegen/GenTypes.scala b/src/compiler/scala/reflect/reify/codegen/GenTypes.scala index 7aa87dc2f8..ca44938f50 100644 --- a/src/compiler/scala/reflect/reify/codegen/GenTypes.scala +++ b/src/compiler/scala/reflect/reify/codegen/GenTypes.scala @@ -74,7 +74,6 @@ trait GenTypes { if (reifyDebug) println("splicing " + tpe) val tagFlavor = if (concrete) tpnme.TypeTag.toString else tpnme.WeakTypeTag.toString - val key = (tagFlavor, tpe.typeSymbol) // if this fails, it might produce the dreaded "erroneous or inaccessible type" error // to find out the whereabouts of the error run scalac with -Ydebug if (reifyDebug) println("launching implicit search for %s.%s[%s]".format(universe, tagFlavor, tpe)) diff --git a/src/compiler/scala/reflect/reify/phases/Reshape.scala b/src/compiler/scala/reflect/reify/phases/Reshape.scala index 9a1732a872..f31c3d4755 100644 --- a/src/compiler/scala/reflect/reify/phases/Reshape.scala +++ b/src/compiler/scala/reflect/reify/phases/Reshape.scala @@ -48,13 +48,13 @@ trait Reshape { val Template(parents, self, body) = impl var body1 = trimAccessors(classDef, reshapeLazyVals(body)) body1 = trimSyntheticCaseClassMembers(classDef, body1) - var impl1 = Template(parents, self, body1).copyAttrs(impl) + val impl1 = Template(parents, self, body1).copyAttrs(impl) ClassDef(mods, name, params, impl1).copyAttrs(classDef) case moduledef @ ModuleDef(mods, name, impl) => val Template(parents, self, body) = impl var body1 = trimAccessors(moduledef, reshapeLazyVals(body)) body1 = trimSyntheticCaseClassMembers(moduledef, body1) - var impl1 = Template(parents, self, body1).copyAttrs(impl) + val impl1 = Template(parents, self, body1).copyAttrs(impl) ModuleDef(mods, name, impl1).copyAttrs(moduledef) case template @ Template(parents, self, body) => val discardedParents = parents collect { case tt: TypeTree => tt } filter isDiscarded @@ -116,7 +116,6 @@ trait Reshape { private def toPreTyperModifiers(mods: Modifiers, sym: Symbol) = { if (!sym.annotations.isEmpty) { - val Modifiers(flags, privateWithin, annotations) = mods val postTyper = sym.annotations filter (_.original != EmptyTree) if (reifyDebug && !postTyper.isEmpty) println("reify symbol annotations for: " + sym) if (reifyDebug && !postTyper.isEmpty) println("originals are: " + sym.annotations) @@ -252,7 +251,7 @@ trait Reshape { val DefDef(mods0, name0, _, _, tpt0, rhs0) = ddef val name1 = nme.dropLocalSuffix(name0) val Modifiers(flags0, privateWithin0, annotations0) = mods0 - var flags1 = (flags0 & GetterFlags) & ~(STABLE | ACCESSOR | METHOD) + val flags1 = (flags0 & GetterFlags) & ~(STABLE | ACCESSOR | METHOD) val mods1 = Modifiers(flags1, privateWithin0, annotations0) setPositions mods0.positions val mods2 = toPreTyperModifiers(mods1, ddef.symbol) ValDef(mods2, name1, tpt0, extractRhs(rhs0)) @@ -267,7 +266,7 @@ trait Reshape { def detectBeanAccessors(prefix: String): Unit = { if (defdef.name.startsWith(prefix)) { - var name = defdef.name.toString.substring(prefix.length) + val name = defdef.name.toString.substring(prefix.length) def uncapitalize(s: String) = if (s.length == 0) "" else { val chars = s.toCharArray; chars(0) = chars(0).toLower; new String(chars) } def findValDef(name: String) = (symdefs.values collect { case vdef: ValDef if nme.dropLocalSuffix(vdef.name).toString == name => vdef }).headOption val valdef = findValDef(name).orElse(findValDef(uncapitalize(name))).orNull @@ -279,11 +278,11 @@ trait Reshape { detectBeanAccessors("is") }); - var stats1 = stats flatMap { + val stats1 = stats flatMap { case vdef @ ValDef(mods, name, tpt, rhs) if !mods.isLazy => val mods1 = if (accessors.contains(vdef)) { val ddef = accessors(vdef)(0) // any accessor will do - val Modifiers(flags, privateWithin, annotations) = mods + val Modifiers(flags, _, annotations) = mods var flags1 = flags & ~LOCAL if (!ddef.symbol.isPrivate) flags1 = flags1 & ~PRIVATE val privateWithin1 = ddef.mods.privateWithin diff --git a/src/compiler/scala/reflect/reify/utils/Extractors.scala b/src/compiler/scala/reflect/reify/utils/Extractors.scala index b60d15c1d4..50bd309b52 100644 --- a/src/compiler/scala/reflect/reify/utils/Extractors.scala +++ b/src/compiler/scala/reflect/reify/utils/Extractors.scala @@ -187,7 +187,7 @@ trait Extractors { Literal(Constant(origin: String))))) if uref1.name == nme.UNIVERSE_SHORT && build1 == nme.build && newFreeTerm == nme.newFreeTerm && uref2.name == nme.UNIVERSE_SHORT && build2 == nme.build && flagsFromBits == nme.flagsFromBits => - Some(uref1, name, reifyBinding(tree), flags, origin) + Some((uref1, name, reifyBinding(tree), flags, origin)) case _ => None } @@ -204,7 +204,7 @@ trait Extractors { Literal(Constant(origin: String))))) if uref1.name == nme.UNIVERSE_SHORT && build1 == nme.build && newFreeType == nme.newFreeType && uref2.name == nme.UNIVERSE_SHORT && build2 == nme.build && flagsFromBits == nme.flagsFromBits => - Some(uref1, name, reifyBinding(tree), flags, origin) + Some((uref1, name, reifyBinding(tree), flags, origin)) case _ => None } diff --git a/src/compiler/scala/reflect/reify/utils/NodePrinters.scala b/src/compiler/scala/reflect/reify/utils/NodePrinters.scala index 000e500c69..9b7cc9f2ae 100644 --- a/src/compiler/scala/reflect/reify/utils/NodePrinters.scala +++ b/src/compiler/scala/reflect/reify/utils/NodePrinters.scala @@ -25,8 +25,8 @@ trait NodePrinters { // Rolling a full-fledged, robust TreePrinter would be several times more code. // Also as of late we have tests that ensure that UX won't be broken by random changes to the reifier. val lines = (tree.toString.split(EOL) drop 1 dropRight 1).toList splitAt 2 - var (List(universe, mirror), reification) = lines - reification = (for (line <- reification) yield { + val (List(universe, mirror), reification0) = lines + val reification = (for (line <- reification0) yield { var s = line substring 2 s = s.replace(nme.UNIVERSE_PREFIX.toString, "") s = s.replace(".apply", "") diff --git a/src/compiler/scala/reflect/reify/utils/SymbolTables.scala b/src/compiler/scala/reflect/reify/utils/SymbolTables.scala index 2607b8f9b7..babea450c1 100644 --- a/src/compiler/scala/reflect/reify/utils/SymbolTables.scala +++ b/src/compiler/scala/reflect/reify/utils/SymbolTables.scala @@ -102,7 +102,7 @@ trait SymbolTables { newSymtab = newSymtab map { case ((sym, tree)) => val ValDef(mods, primaryName, tpt, rhs) = tree val tree1 = - if (!(newAliases contains (sym, primaryName))) { + if (!(newAliases contains ((sym, primaryName)))) { val primaryName1 = newAliases.find(_._1 == sym).get._2 ValDef(mods, primaryName1, tpt, rhs).copyAttrs(tree) } else tree @@ -138,7 +138,7 @@ trait SymbolTables { var result = new SymbolTable(original = Some(encoded)) encoded foreach (entry => (entry.attachments.get[ReifyBindingAttachment], entry.attachments.get[ReifyAliasAttachment]) match { case (Some(ReifyBindingAttachment(_)), _) => result += entry - case (_, Some(ReifyAliasAttachment(sym, alias))) => result = new SymbolTable(result.symtab, result.aliases :+ (sym, alias)) + case (_, Some(ReifyAliasAttachment(sym, alias))) => result = new SymbolTable(result.symtab, result.aliases :+ ((sym, alias))) case _ => // do nothing, this is boilerplate that can easily be recreated by subsequent `result.encode` }) result diff --git a/src/compiler/scala/tools/ant/Pack200Task.scala b/src/compiler/scala/tools/ant/Pack200Task.scala index ff18ddff91..117a1c9def 100644 --- a/src/compiler/scala/tools/ant/Pack200Task.scala +++ b/src/compiler/scala/tools/ant/Pack200Task.scala @@ -99,8 +99,8 @@ class Pack200Task extends ScalaMatchingTask { private def getFileList: List[File] = { var files: List[File] = Nil val fs = getImplicitFileSet - var ds = fs.getDirectoryScanner(getProject()) - var dir = fs.getDir(getProject()) + val ds = fs.getDirectoryScanner(getProject()) + val dir = fs.getDir(getProject()) for (filename <- ds.getIncludedFiles() if filename.toLowerCase.endsWith(".jar")) { val file = new File(dir, filename) diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index 3e77fc982d..69daa8ce6f 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -298,7 +298,6 @@ class Global(var currentSettings: Settings, var reporter: Reporter) private val reader: SourceReader = { val defaultEncoding = Properties.sourceEncoding - val defaultReader = Properties.sourceReader def loadCharset(name: String) = try Some(Charset.forName(name)) @@ -1726,7 +1725,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter) val printer = new icodes.TextPrinter(null, icodes.linearizer) icodes.classes.values.foreach((cls) => { val suffix = if (cls.symbol.hasModuleFlag) "$.icode" else ".icode" - var file = getFile(cls.symbol, suffix) + val file = getFile(cls.symbol, suffix) // if (file.exists()) // file = new File(file.getParentFile(), file.getName() + "1") try { diff --git a/src/compiler/scala/tools/nsc/PhaseAssembly.scala b/src/compiler/scala/tools/nsc/PhaseAssembly.scala index 46cdc6a4a0..6c339fb5ae 100644 --- a/src/compiler/scala/tools/nsc/PhaseAssembly.scala +++ b/src/compiler/scala/tools/nsc/PhaseAssembly.scala @@ -55,7 +55,7 @@ trait PhaseAssembly { * node object does not exist, then create it. */ def getNodeByPhase(phs: SubComponent): Node = { - var node: Node = getNodeByPhase(phs.phaseName) + val node: Node = getNodeByPhase(phs.phaseName) node.phaseobj match { case None => node.phaseobj = Some(List[SubComponent](phs)) @@ -75,7 +75,7 @@ trait PhaseAssembly { * list of the nodes */ def softConnectNodes(frm: Node, to: Node) { - var e = new Edge(frm, to, false) + val e = new Edge(frm, to, false) this.edges += e frm.after += e @@ -87,7 +87,7 @@ trait PhaseAssembly { * list of the nodes */ def hardConnectNodes(frm: Node, to: Node) { - var e = new Edge(frm, to, true) + val e = new Edge(frm, to, true) this.edges += e frm.after += e @@ -164,7 +164,7 @@ trait PhaseAssembly { } else { - var promote = hl.to.before.filter(e => (!e.hard)) + val promote = hl.to.before.filter(e => (!e.hard)) hl.to.before.clear sanity foreach (edge => hl.to.before += edge) for (edge <- promote) { @@ -245,7 +245,7 @@ trait PhaseAssembly { for (phs <- phsSet) { - var fromnode = graph.getNodeByPhase(phs) + val fromnode = graph.getNodeByPhase(phs) phs.runsRightAfter match { case None => @@ -306,7 +306,7 @@ trait PhaseAssembly { sbuf.append("\"" + node.allPhaseNames + "(" + node.level + ")" + "\" [color=\"#0000ff\"]\n") } sbuf.append("}\n") - var out = new BufferedWriter(new FileWriter(filename)) + val out = new BufferedWriter(new FileWriter(filename)) out.write(sbuf.toString) out.flush() out.close() diff --git a/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala b/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala index be7a6295b4..3141227bad 100644 --- a/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala +++ b/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala @@ -529,7 +529,6 @@ abstract class TreeBrowsers { * attributes */ def symbolAttributes(t: Tree): String = { val s = t.symbol - var att = "" if ((s ne null) && (s != NoSymbol)) { var str = flagsToString(s.flags) diff --git a/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala b/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala index 9c03b10157..bb003ef0e1 100755 --- a/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala @@ -124,7 +124,6 @@ trait MarkupParsers { val start = curOffset val key = xName xEQ - val delim = ch val mid = curOffset val value: Tree = ch match { case '"' | '\'' => @@ -410,7 +409,7 @@ trait MarkupParsers { * | Name [S] '/' '>' */ def xPattern: Tree = { - var start = curOffset + val start = curOffset val qname = xName debugLastStartElement.push((start, qname)) xSpaceOpt diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index 380fd1fcaa..722e6d1e9a 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -919,7 +919,7 @@ self => ) def compoundTypeRest(t: Tree): Tree = { - var ts = new ListBuffer[Tree] += t + val ts = new ListBuffer[Tree] += t while (in.token == WITH) { in.nextToken() ts += annotType() @@ -1270,7 +1270,7 @@ self => def expr(): Tree = expr(Local) def expr(location: Int): Tree = { - var savedPlaceholderParams = placeholderParams + val savedPlaceholderParams = placeholderParams placeholderParams = List() var res = expr0(location) if (!placeholderParams.isEmpty && !isWildcard(res)) { @@ -1320,7 +1320,6 @@ self => parseTry case WHILE => def parseWhile = { - val start = in.offset atPos(in.skipToken()) { val lname: Name = freshTermName(nme.WHILE_PREFIX) val cond = condExpr() @@ -1332,7 +1331,6 @@ self => parseWhile case DO => def parseDo = { - val start = in.offset atPos(in.skipToken()) { val lname: Name = freshTermName(nme.DO_WHILE_PREFIX) val body = expr() @@ -1796,7 +1794,6 @@ self => * }}} */ def pattern2(): Tree = { - val nameOffset = in.offset val p = pattern3() if (in.token != AT) p @@ -1909,7 +1906,7 @@ self => val start = in.offset in.token match { case IDENTIFIER | BACKQUOTED_IDENT | THIS => - var t = stableId() + val t = stableId() in.token match { case INTLIT | LONGLIT | FLOATLIT | DOUBLELIT => t match { @@ -2616,7 +2613,6 @@ self => in.nextToken() newLinesOpt() atPos(start, in.offset) { - val nameOffset = in.offset val name = identForType() // @M! a type alias as well as an abstract type may declare type parameters val tparams = typeParamClauseOpt(name, null) @@ -2893,7 +2889,6 @@ self => * }}} */ def packaging(start: Int): Tree = { - val nameOffset = in.offset val pkg = pkgQualId() val stats = inBracesOrNil(topStatSeq()) makePackaging(start, pkg, stats) @@ -3103,7 +3098,6 @@ self => ts ++= topStatSeq() } } else { - val nameOffset = in.offset in.flushDoc val pkg = pkgQualId() diff --git a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala index 3ff52cc32b..bc7a679560 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala @@ -450,7 +450,7 @@ abstract class TreeBuilder { def combine(gs: List[ValFrom]): ValFrom = (gs: @unchecked) match { case g :: Nil => g case ValFrom(pos1, pat1, rhs1) :: gs2 => - val ValFrom(pos2, pat2, rhs2) = combine(gs2) + val ValFrom(_, pat2, rhs2) = combine(gs2) ValFrom(pos1, makeTuple(List(pat1, pat2), false), Apply(Select(rhs1, nme.zip), List(rhs2))) } makeForYield(List(combine(gs)), body) diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala index d4126f2786..9a7aafd787 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala @@ -432,7 +432,7 @@ abstract class GenICode extends SubComponent { private def genPrimitiveOp(tree: Apply, ctx: Context, expectedType: TypeKind): (Context, TypeKind) = { val sym = tree.symbol - val Apply(fun @ Select(receiver, _), args) = tree + val Apply(fun @ Select(receiver, _), _) = tree val code = scalaPrimitives.getPrimitive(sym, receiver.tpe) if (scalaPrimitives.isArithmeticOp(code)) @@ -543,9 +543,8 @@ abstract class GenICode extends SubComponent { // emits CIL_LOAD_ARRAY_ITEM_ADDRESS case Apply(fun, args) => if (isPrimitive(fun.symbol)) { - val sym = tree.symbol - val Apply(fun @ Select(receiver, _), args) = tree + val Select(receiver, _) = fun val code = scalaPrimitives.getPrimitive(sym, receiver.tpe) if (isArrayOp(code)) { @@ -858,7 +857,7 @@ abstract class GenICode extends SubComponent { // we store this boxed value to a local, even if not really needed. // boxing optimization might use it, and dead code elimination will // take care of unnecessary stores - var loc1 = ctx.makeLocal(tree.pos, expr.tpe, "boxed") + val loc1 = ctx.makeLocal(tree.pos, expr.tpe, "boxed") ctx1.bb.emit(STORE_LOCAL(loc1)) ctx1.bb.emit(LOAD_LOCAL(loc1)) } @@ -1104,7 +1103,7 @@ abstract class GenICode extends SubComponent { case Match(selector, cases) => def genLoadMatch = { debuglog("Generating SWITCH statement."); - 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) + 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) val afterCtx = ctx1.newBlock var caseCtx: Context = null generatedType = toTypeKind(tree.tpe) @@ -2116,7 +2115,7 @@ abstract class GenICode extends SubComponent { } else ctx - val finalizerExh = if (finalizer != EmptyTree) Some({ + if (finalizer != EmptyTree) { val exh = outerCtx.newExceptionHandler(NoSymbol, toTypeKind(finalizer.tpe), finalizer.pos) // finalizer covers exception handlers this.addActiveHandler(exh) // .. and body aswell val ctx = finalizerCtx.enterExceptionHandler(exh) @@ -2129,21 +2128,20 @@ abstract class GenICode extends SubComponent { ctx1.bb.enterIgnoreMode; ctx1.bb.close finalizerCtx.endHandler() - exh - }) else None - - val exhs = handlers.map { case (sym, kind, handler) => // def genWildcardHandler(sym: Symbol): (Symbol, TypeKind, Context => Context) = - val exh = this.newExceptionHandler(sym, kind, tree.pos) - var ctx1 = outerCtx.enterExceptionHandler(exh) - ctx1.addFinalizer(finalizer, finalizerCtx) - loadException(ctx1, exh, tree.pos) - ctx1 = handler(ctx1) - // emit finalizer - val ctx2 = emitFinalizer(ctx1) - ctx2.bb.closeWith(JUMP(afterCtx.bb)) - outerCtx.endHandler() - exh - } + } + + for ((sym, kind, handler) <- handlers) { + val exh = this.newExceptionHandler(sym, kind, tree.pos) + var ctx1 = outerCtx.enterExceptionHandler(exh) + ctx1.addFinalizer(finalizer, finalizerCtx) + loadException(ctx1, exh, tree.pos) + ctx1 = handler(ctx1) + // emit finalizer + val ctx2 = emitFinalizer(ctx1) + ctx2.bb.closeWith(JUMP(afterCtx.bb)) + outerCtx.endHandler() + } + val bodyCtx = this.newBlock if (finalizer != EmptyTree) bodyCtx.addFinalizer(finalizer, finalizerCtx) diff --git a/src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala b/src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala index 5ccbbf997e..bc42605246 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala @@ -294,7 +294,7 @@ abstract class ICodeCheckers { else prefix + " with initial stack " + initial.types.mkString("[", ", ", "]") }) - var stack = new TypeStack(initial) + val stack = new TypeStack(initial) def checkStack(len: Int) { if (stack.length < len) ICodeChecker.this.icodeError("Expected at least " + len + " elements on the stack", stack) diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/ReachingDefinitions.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/ReachingDefinitions.scala index 6f9302c97b..6cd349df01 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/analysis/ReachingDefinitions.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/ReachingDefinitions.scala @@ -155,7 +155,7 @@ abstract class ReachingDefinitions { import lattice.IState def updateReachingDefinition(b: BasicBlock, idx: Int, rd: ListSet[Definition]): ListSet[Definition] = { val STORE_LOCAL(local) = b(idx) - var tmp = local + val tmp = local (rd filter { case (l, _, _) => l != tmp }) + ((tmp, b, idx)) } @@ -197,7 +197,7 @@ abstract class ReachingDefinitions { def findDefs(bb: BasicBlock, idx: Int, m: Int, depth: Int): List[(BasicBlock, Int)] = if (idx > 0) { assert(bb.closed, bb) - var instrs = bb.getArray + val instrs = bb.getArray var res: List[(BasicBlock, Int)] = Nil var i = idx var n = m diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala index cdf2788284..c4f4c60846 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala @@ -136,7 +136,7 @@ abstract class TypeFlowAnalysis { timer.start // icodes.lubs0 = 0 forwardAnalysis(blockTransfer) - val t = timer.stop + timer.stop if (settings.debug.value) { linearizer.linearize(method).foreach(b => if (b != method.startBlock) assert(visited.contains(b), @@ -326,7 +326,6 @@ abstract class TypeFlowAnalysis { class TransferFunction(consumed: Int, gens: List[Gen]) extends (lattice.Elem => lattice.Elem) { def apply(in: lattice.Elem): lattice.Elem = { val out = lattice.IState(new VarBinding(in.vars), new TypeStack(in.stack)) - val bindings = out.vars val stack = out.stack out.stack.pop(consumed) @@ -389,7 +388,7 @@ abstract class TypeFlowAnalysis { timer.start forwardAnalysis(blockTransfer) - val t = timer.stop + timer.stop /* Now that `forwardAnalysis(blockTransfer)` has finished, all inlining candidates can be found in `remainingCALLs`, whose keys are callsites and whose values are pieces of information about the typestack just before the callsite in question. diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BytecodeWriters.scala b/src/compiler/scala/tools/nsc/backend/jvm/BytecodeWriters.scala index 086327934b..fcd196eff7 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/BytecodeWriters.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/BytecodeWriters.scala @@ -102,7 +102,7 @@ trait BytecodeWriters { super.writeClass(label, jclassName, jclassBytes, sym) val pathName = jclassName - var dumpFile = pathName.split("[./]").foldLeft(baseDir: Path) (_ / _) changeExtension "class" toFile; + val dumpFile = pathName.split("[./]").foldLeft(baseDir: Path) (_ / _) changeExtension "class" toFile; dumpFile.parent.createDirectory() val outstream = new DataOutputStream(new FileOutputStream(dumpFile.path)) diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala index a6e4339d82..34f854a072 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala @@ -81,7 +81,6 @@ abstract class GenASM extends SubComponent with BytecodeWriters { // 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") @@ -592,7 +591,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters { collectInnerClass(sym) - var hasInternalName = (sym.isClass || (sym.isModule && !sym.isMethod)) + val hasInternalName = (sym.isClass || (sym.isModule && !sym.isMethod)) val cachedJN = javaNameCache.getOrElseUpdate(sym, { if (hasInternalName) { sym.javaBinaryName } else { sym.javaSimpleName } @@ -1172,7 +1171,6 @@ abstract class GenASM extends SubComponent with BytecodeWriters { debuglog("Dumping mirror class for object: " + moduleClass) val linkedClass = moduleClass.companionClass - val linkedModule = linkedClass.companionSymbol lazy val conflictingNames: Set[Name] = { (linkedClass.info.members collect { case sym if sym.name.isTermName => sym.name }).toSet } @@ -2212,7 +2210,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters { def getMerged(): scala.collection.Map[Local, List[Interval]] = { // TODO should but isn't: unbalanced start(s) of scope(s) - val shouldBeEmpty = pending filter { p => val Pair(k, st) = p; st.nonEmpty }; + val shouldBeEmpty = pending filter { p => val Pair(_, st) = p; st.nonEmpty }; val merged = mutable.Map[Local, List[Interval]]() def addToMerged(lv: Local, start: Label, end: Label) { val intv = Interval(start, end) @@ -2275,7 +2273,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters { } // quest for deterministic output that Map.toList doesn't provide (so that ant test.stability doesn't complain). val srtd = fltnd.sortBy { kr => - val Triple(name: String, local: Local, intrvl: Interval) = kr + val Triple(name: String, _, intrvl: Interval) = kr Triple(intrvl.start, intrvl.end - intrvl.start, name) // ie sort by (start, length, name) } @@ -2510,7 +2508,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters { def genFldsInstr() = (instr: @unchecked) match { case lf @ LOAD_FIELD(field, isStatic) => - var owner = javaName(lf.hostClass) + val owner = javaName(lf.hostClass) debuglog("LOAD_FIELD with owner: " + owner + " flags: " + Flags.flagsToString(field.owner.flags)) val fieldJName = javaName(field) val fieldDescr = descriptor(field) @@ -3343,8 +3341,8 @@ abstract class GenASM extends SubComponent with BytecodeWriters { var wasReduced = false val entryPoints: List[BasicBlock] = m.startBlock :: (m.exh map (_.startBlock)); - var elided = mutable.Set.empty[BasicBlock] // debug - var newTargets = mutable.Set.empty[BasicBlock] // debug + val elided = mutable.Set.empty[BasicBlock] // debug + val newTargets = mutable.Set.empty[BasicBlock] // debug for (ep <- entryPoints) { var reachable = directSuccStar(ep) // this list may contain blocks belonging to jump-chains that we'll skip over diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala index 6797b15cc6..2043a34ef6 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala @@ -73,7 +73,6 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with // 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") @@ -514,9 +513,6 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with * @author Ross Judson (ross.judson@soletta.com) */ def genBeanInfoClass(c: IClass) { - val description = c.symbol getAnnotation BeanDescriptionAttr - // informProgress(description.toString) - val beanInfoClass = fjbgContext.JClass(javaFlags(c.symbol), javaName(c.symbol) + "BeanInfo", "scala/beans/ScalaBeanInfo", @@ -1063,7 +1059,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with var i = 0 var index = 0 - var argTypes = mirrorMethod.getArgumentTypes() + val argTypes = mirrorMethod.getArgumentTypes() while (i < argTypes.length) { mirrorCode.emitLOAD(index, argTypes(i)) index += argTypes(i).getSize() @@ -1095,7 +1091,6 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with val className = jclass.getName val linkedClass = moduleClass.companionClass - val linkedModule = linkedClass.companionSymbol lazy val conflictingNames: Set[Name] = { linkedClass.info.members collect { case sym if sym.name.isTermName => sym.name } toSet } @@ -1339,7 +1334,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with case LOAD_LOCAL(local) => jcode.emitLOAD(indexOf(local), javaType(local.kind)) case lf @ LOAD_FIELD(field, isStatic) => - var owner = javaName(lf.hostClass) + val owner = javaName(lf.hostClass) debuglog("LOAD_FIELD with owner: " + owner + " flags: " + Flags.flagsToString(field.owner.flags)) val fieldJName = javaName(field) diff --git a/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala b/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala index 8197e564d1..21b62b0e6f 100644 --- a/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala +++ b/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala @@ -258,9 +258,9 @@ abstract class GenMSIL extends SubComponent { * and thus shouldn't be added by this method. */ def addAttributes(member: ICustomAttributeSetter, annotations: List[AnnotationInfo]) { - val attributes = annotations.map(_.atp.typeSymbol).collect { - case definitions.TransientAttr => null // TODO this is just an example - } + // val attributes = annotations.map(_.atp.typeSymbol).collect { + // case definitions.TransientAttr => null // TODO this is just an example + // } return // TODO: implement at some point } @@ -823,7 +823,7 @@ abstract class GenMSIL extends SubComponent { def loadFieldOrAddress(field: Symbol, isStatic: Boolean, msg: String, loadAddr : Boolean) { debuglog(msg + " with owner: " + field.owner + " flags: " + Flags.flagsToString(field.owner.flags)) - var fieldInfo = fields.get(field) match { + val fieldInfo = fields.get(field) match { case Some(fInfo) => fInfo case None => val fInfo = getType(field.owner).GetField(msilName(field)) @@ -1254,7 +1254,7 @@ abstract class GenMSIL extends SubComponent { mcode.Emit(OpCodes.Stloc, switchLocal) var i = 0 for (l <- tags) { - var targetLabel = labels(branches(i)) + val targetLabel = labels(branches(i)) for (i <- l) { mcode.Emit(OpCodes.Ldloc, switchLocal) loadI4(i, mcode) @@ -1871,7 +1871,7 @@ abstract class GenMSIL extends SubComponent { val sym = ifield.symbol debuglog("Adding field: " + sym.fullName) - var attributes = msilFieldFlags(sym) + val attributes = msilFieldFlags(sym) val fieldTypeWithCustomMods = new PECustomMod(msilType(sym.tpe), customModifiers(sym.annotations)) @@ -1905,7 +1905,7 @@ abstract class GenMSIL extends SubComponent { val ownerType = getType(sym.enclClass).asInstanceOf[TypeBuilder] assert(mtype == ownerType, "mtype = " + mtype + "; ownerType = " + ownerType) - var paramTypes = msilParamTypes(sym) + val paramTypes = msilParamTypes(sym) val attr = msilMethodFlags(sym) if (m.symbol.isClassConstructor) { @@ -1917,7 +1917,7 @@ abstract class GenMSIL extends SubComponent { mapConstructor(sym, constr) addAttributes(constr, sym.annotations) } else { - var resType = msilType(m.returnType) + val resType = msilType(m.returnType) val method = ownerType.DefineMethod(msilName(sym), attr, resType, paramTypes) for (i <- 0.until(paramTypes.length)) { @@ -2037,7 +2037,6 @@ abstract class GenMSIL extends SubComponent { } private def generateMirrorClass(sym: Symbol) { - val tBuilder = getType(sym) assert(sym.isModuleClass, "Can't generate Mirror-Class for the Non-Module class " + sym) debuglog("Dumping mirror class for object: " + sym) val moduleName = msilName(sym) diff --git a/src/compiler/scala/tools/nsc/backend/opt/ClosureElimination.scala b/src/compiler/scala/tools/nsc/backend/opt/ClosureElimination.scala index bcdcbfd435..1c57120762 100644 --- a/src/compiler/scala/tools/nsc/backend/opt/ClosureElimination.scala +++ b/src/compiler/scala/tools/nsc/backend/opt/ClosureElimination.scala @@ -120,7 +120,7 @@ abstract class ClosureElimination extends SubComponent { case LOAD_FIELD(f, false) /* if accessible(f, m.symbol) */ => def replaceFieldAccess(r: Record) { - val Record(cls, bindings) = r + val Record(cls, _) = r info.getFieldNonRecordValue(r, f) foreach { v => bb.replaceInstruction(i, DROP(REFERENCE(cls)) :: valueToInstruction(v) :: Nil) debuglog(s"replaced $i with $v") diff --git a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala index ab5184dcbd..595a40fdd3 100644 --- a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala +++ b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala @@ -322,8 +322,8 @@ abstract class Inliners extends SubComponent { if (settings.debug.value) inlineLog("caller", ownedName(m.symbol), "in " + m.symbol.owner.fullName) - var sizeBeforeInlining = m.code.blockCount - var instrBeforeInlining = m.code.instructionCount + val sizeBeforeInlining = m.code.blockCount + val instrBeforeInlining = m.code.instructionCount var retry = false var count = 0 @@ -479,7 +479,7 @@ abstract class Inliners extends SubComponent { * As a whole, both `preInline()` invocations amount to priming the inlining process, * so that the first TFA that is run afterwards is able to gain more information as compared to a cold-start. */ - val totalPreInlines = { + /*val totalPreInlines = */ { // Val name commented out to emphasize it is never used val firstRound = preInline(true) if(firstRound == 0) 0 else (firstRound + preInline(false)) } @@ -571,7 +571,6 @@ abstract class Inliners extends SubComponent { m.normalize if (sizeBeforeInlining > 0) { val instrAfterInlining = m.code.instructionCount - val prefix = if ((instrAfterInlining > 2 * instrBeforeInlining) && (instrAfterInlining > 200)) "!!" else "" val inlinings = caller.inlinedCalls if (inlinings > 0) { val s1 = s"instructions $instrBeforeInlining -> $instrAfterInlining" diff --git a/src/compiler/scala/tools/nsc/dependencies/Changes.scala b/src/compiler/scala/tools/nsc/dependencies/Changes.scala index c8ff700208..b3cacee20a 100644 --- a/src/compiler/scala/tools/nsc/dependencies/Changes.scala +++ b/src/compiler/scala/tools/nsc/dependencies/Changes.scala @@ -165,7 +165,6 @@ abstract class Changes { /** Return the list of changes between 'from' and 'toSym.info'. */ def changeSet(from: Type, toSym: Symbol): List[Change] = { - implicit val defaultReason = "types" implicit val defaultStrictTypeRefTest = true val to = toSym.info diff --git a/src/compiler/scala/tools/nsc/doc/html/page/Template.scala b/src/compiler/scala/tools/nsc/doc/html/page/Template.scala index 919a45aefc..20c143cd17 100644 --- a/src/compiler/scala/tools/nsc/doc/html/page/Template.scala +++ b/src/compiler/scala/tools/nsc/doc/html/page/Template.scala @@ -527,7 +527,7 @@ class Template(universe: doc.Universe, generator: DiagramGenerator, tpl: DocTemp val sourceLink: Seq[scala.xml.Node] = mbr match { case dtpl: DocTemplateEntity if (isSelf && dtpl.sourceUrl.isDefined && dtpl.inSource.isDefined && !isReduced) => - val (absFile, line) = dtpl.inSource.get + val (absFile, _) = dtpl.inSource.get <dt>Source</dt> <dd>{ <a href={ dtpl.sourceUrl.get.toString } target="_blank">{ Text(absFile.file.getName) }</a> }</dd> case _ => NodeSeq.Empty @@ -651,7 +651,6 @@ class Template(universe: doc.Universe, generator: DiagramGenerator, tpl: DocTemp case dtpl: DocTemplateEntity if isSelf && !isReduced => val diagram = f(dtpl) if (diagram.isDefined) { - val s = universe.settings val diagramSvg = generator.generate(diagram.get, tpl, this) if (diagramSvg != NodeSeq.Empty) { <div class="toggleContainer block diagram-container" id={ id + "-container"}> diff --git a/src/compiler/scala/tools/nsc/doc/html/page/diagram/DotDiagramGenerator.scala b/src/compiler/scala/tools/nsc/doc/html/page/diagram/DotDiagramGenerator.scala index 8c1e9b0fe0..f4608bdb8e 100644 --- a/src/compiler/scala/tools/nsc/doc/html/page/diagram/DotDiagramGenerator.scala +++ b/src/compiler/scala/tools/nsc/doc/html/page/diagram/DotDiagramGenerator.scala @@ -211,7 +211,7 @@ class DotDiagramGenerator(settings: doc.Settings) extends DiagramGenerator { def escape(name: String) = name.replace("&", "&").replace("<", "<").replace(">", ">"); // assemble node attribues in a map - var attr = scala.collection.mutable.Map[String, String]() + val attr = scala.collection.mutable.Map[String, String]() // link node.doctpl match { diff --git a/src/compiler/scala/tools/nsc/doc/html/page/diagram/DotRunner.scala b/src/compiler/scala/tools/nsc/doc/html/page/diagram/DotRunner.scala index 5cdd5c74a4..be7c27a4ae 100644 --- a/src/compiler/scala/tools/nsc/doc/html/page/diagram/DotRunner.scala +++ b/src/compiler/scala/tools/nsc/doc/html/page/diagram/DotRunner.scala @@ -183,7 +183,7 @@ class DotProcess(settings: doc.Settings) { private[this] def outputFn(stdOut: InputStream): Unit = { val reader = new BufferedReader(new InputStreamReader(stdOut)) - var buffer: StringBuilder = new StringBuilder() + val buffer: StringBuilder = new StringBuilder() try { var line = reader.readLine while (!error && line != null) { @@ -209,7 +209,6 @@ class DotProcess(settings: doc.Settings) { private[this] def errorFn(stdErr: InputStream): Unit = { val reader = new BufferedReader(new InputStreamReader(stdErr)) - var buffer: StringBuilder = new StringBuilder() try { var line = reader.readLine while (line != null) { @@ -225,4 +224,4 @@ class DotProcess(settings: doc.Settings) { errorBuffer.append(" Error thread in " + templateName + ": Exception: " + exc + "\n") } } -}
\ No newline at end of file +} diff --git a/src/compiler/scala/tools/nsc/doc/model/MemberLookup.scala b/src/compiler/scala/tools/nsc/doc/model/MemberLookup.scala index 5257db1610..2a28d4c589 100644 --- a/src/compiler/scala/tools/nsc/doc/model/MemberLookup.scala +++ b/src/compiler/scala/tools/nsc/doc/model/MemberLookup.scala @@ -19,7 +19,7 @@ trait MemberLookup { def memberLookup(pos: Position, query: String, inTplOpt: Option[DocTemplateImpl]): LinkTo = { assert(modelFinished) - var members = breakMembers(query) + val members = breakMembers(query) //println(query + " => " + members) // (1) First look in the root package, as most of the links are qualified diff --git a/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala b/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala index 2ca80c9282..010bb98549 100644 --- a/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala +++ b/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala @@ -853,7 +853,6 @@ class ModelFactory(val global: Global, val settings: doc.Settings) { } def findMember(aSym: Symbol, inTpl: DocTemplateImpl): Option[MemberImpl] = { - val tplSym = normalizeTemplate(aSym.owner) inTpl.members.find(_.sym == aSym) } @@ -1007,7 +1006,7 @@ class ModelFactory(val global: Global, val settings: doc.Settings) { def makeQualifiedName(sym: Symbol, relativeTo: Option[Symbol] = None): String = { val stop = relativeTo map (_.ownerChain.toSet) getOrElse Set[Symbol]() var sym1 = sym - var path = new StringBuilder() + val path = new StringBuilder() // var path = List[Symbol]() while ((sym1 != NoSymbol) && (path.isEmpty || !stop(sym1))) { @@ -1076,7 +1075,7 @@ class ModelFactory(val global: Global, val settings: doc.Settings) { def findExternalLink(sym: Symbol, name: String): Option[LinkTo] = { val sym1 = if (sym == AnyClass || sym == AnyRefClass || sym == AnyValClass || sym == NothingClass) ListClass - else if (sym.isPackage) + else if (sym.isPackage) /* Get package object which has associatedFile ne null */ sym.info.member(newTermName("package")) else sym diff --git a/src/compiler/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala b/src/compiler/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala index af89978be1..a76f90febb 100644 --- a/src/compiler/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala +++ b/src/compiler/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala @@ -96,7 +96,7 @@ trait ModelFactoryImplicitSupport { // But we don't want that, so we'll simply refuse to find implicit conversions on for Nothing and Null if (!(sym.isClass || sym.isTrait || sym == AnyRefClass) || sym == NothingClass || sym == NullClass) Nil else { - var context: global.analyzer.Context = global.analyzer.rootContext(NoCompilationUnit) + val context: global.analyzer.Context = global.analyzer.rootContext(NoCompilationUnit) val results = global.analyzer.allViewsFrom(sym.tpe_*, context, sym.typeParams) var conversions = results.flatMap(result => makeImplicitConversion(sym, result._1, result._2, context, inTpl)) @@ -387,7 +387,6 @@ trait ModelFactoryImplicitSupport { lazy val memberImpls: List[MemberImpl] = { // Obtain the members inherited by the implicit conversion val memberSyms = toType.members.filter(implicitShouldDocument(_)).toList - val existingSyms = sym.info.members // Debugging part :) debug(sym.nameString + "\n" + "=" * sym.nameString.length()) diff --git a/src/compiler/scala/tools/nsc/doc/model/ModelFactoryTypeSupport.scala b/src/compiler/scala/tools/nsc/doc/model/ModelFactoryTypeSupport.scala index cd86dcb606..8ba1560926 100644 --- a/src/compiler/scala/tools/nsc/doc/model/ModelFactoryTypeSupport.scala +++ b/src/compiler/scala/tools/nsc/doc/model/ModelFactoryTypeSupport.scala @@ -229,7 +229,6 @@ trait ModelFactoryTypeSupport { def appendClauses = { nameBuffer append " forSome {" var first = true - val qset = quantified.toSet for (sym <- quantified) { if (!first) { nameBuffer append ", " } else first = false if (sym.isSingletonExistential) { diff --git a/src/compiler/scala/tools/nsc/doc/model/TreeFactory.scala b/src/compiler/scala/tools/nsc/doc/model/TreeFactory.scala index bd7534ded4..b972649194 100755 --- a/src/compiler/scala/tools/nsc/doc/model/TreeFactory.scala +++ b/src/compiler/scala/tools/nsc/doc/model/TreeFactory.scala @@ -21,7 +21,7 @@ trait TreeFactory { thisTreeFactory: ModelFactory with TreeFactory => def makeTree(rhs: Tree): Option[TreeEntity] = { - var expr = new StringBuilder + val expr = new StringBuilder var refs = new immutable.TreeMap[Int, (Entity, Int)] // start, (Entity to be linked to , end) rhs.pos match { @@ -39,7 +39,7 @@ trait TreeFactory { thisTreeFactory: ModelFactory with TreeFactory => * stores it in tree.refs with its position */ def makeLink(rhs: Tree){ - var start = pos.startOrPoint - firstIndex + val start = pos.startOrPoint - firstIndex val end = pos.endOrPoint - firstIndex if(start != end) { var asym = rhs.symbol diff --git a/src/compiler/scala/tools/nsc/doc/model/comment/CommentFactory.scala b/src/compiler/scala/tools/nsc/doc/model/comment/CommentFactory.scala index 822c11307c..20e2979615 100644 --- a/src/compiler/scala/tools/nsc/doc/model/comment/CommentFactory.scala +++ b/src/compiler/scala/tools/nsc/doc/model/comment/CommentFactory.scala @@ -759,8 +759,7 @@ trait CommentFactory { thisFactory: ModelFactory with CommentFactory with Member def link(): Inline = { val SchemeUri = """([a-z]+:.*)""".r jump("[[") - var parens = 2 + repeatJump('[') - val start = "[" * parens + val parens = 2 + repeatJump('[') val stop = "]" * parens //println("link with " + parens + " matching parens") val target = readUntil { check(stop) || check(" ") } @@ -805,7 +804,7 @@ trait CommentFactory { thisFactory: ModelFactory with CommentFactory with Member */ def normalizeIndentation(_code: String): String = { - var code = _code.trim + val code = _code.trim var maxSkip = Integer.MAX_VALUE var crtSkip = 0 var wsArea = true diff --git a/src/compiler/scala/tools/nsc/doc/model/diagram/DiagramFactory.scala b/src/compiler/scala/tools/nsc/doc/model/diagram/DiagramFactory.scala index db2d0c0175..78bff9d349 100644 --- a/src/compiler/scala/tools/nsc/doc/model/diagram/DiagramFactory.scala +++ b/src/compiler/scala/tools/nsc/doc/model/diagram/DiagramFactory.scala @@ -48,7 +48,7 @@ trait DiagramFactory extends DiagramDirectiveParser { val thisNode = ThisNode(tpl.resultType, Some(tpl))(Some(tpl.qualifiedName + " (this " + tpl.kind + ")")) // superclasses - var superclasses: List[Node] = + val superclasses: List[Node] = tpl.parentTypes.collect { case p: (TemplateEntity, TypeEntity) if !classExcluded(p._1) => NormalNode(p._2, Some(p._1))() }.reverse diff --git a/src/compiler/scala/tools/nsc/interactive/Global.scala b/src/compiler/scala/tools/nsc/interactive/Global.scala index 2e2c772a38..dc66bb7fd7 100644 --- a/src/compiler/scala/tools/nsc/interactive/Global.scala +++ b/src/compiler/scala/tools/nsc/interactive/Global.scala @@ -355,7 +355,7 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "") } // don't forget to service interrupt requests - val iqs = scheduler.dequeueAllInterrupts(_.execute()) + scheduler.dequeueAllInterrupts(_.execute()) debugLog("ShutdownReq: cleaning work queue (%d items)".format(units.size)) debugLog("Cleanup up responses (%d loadedType pending, %d parsedEntered pending)" diff --git a/src/compiler/scala/tools/nsc/interactive/tests/core/CoreTestDefs.scala b/src/compiler/scala/tools/nsc/interactive/tests/core/CoreTestDefs.scala index c8e6b6ccce..704d014eb9 100644 --- a/src/compiler/scala/tools/nsc/interactive/tests/core/CoreTestDefs.scala +++ b/src/compiler/scala/tools/nsc/interactive/tests/core/CoreTestDefs.scala @@ -77,7 +77,8 @@ private[tests] trait CoreTestDefs // askHyperlinkPos for `Int` at (73,19) pi.scala --> class Int in package scala has null sourceFile! val treePath = if (tree.symbol.sourceFile ne null) tree.symbol.sourceFile.path else null val treeName = if (tree.symbol.sourceFile ne null) tree.symbol.sourceFile.name else null - val sourceFile = sourceFiles.find(_.path == treePath) match { + + sourceFiles.find(_.path == treePath) match { case Some(source) => compiler.askLinkPos(tree.symbol, source, r) r.get match { @@ -97,4 +98,4 @@ private[tests] trait CoreTestDefs } } } -}
\ No newline at end of file +} diff --git a/src/compiler/scala/tools/nsc/interpreter/ILoop.scala b/src/compiler/scala/tools/nsc/interpreter/ILoop.scala index 18d0567ff3..d5b5d43baf 100644 --- a/src/compiler/scala/tools/nsc/interpreter/ILoop.scala +++ b/src/compiler/scala/tools/nsc/interpreter/ILoop.scala @@ -279,7 +279,6 @@ class ILoop(in0: Option[BufferedReader], protected val out: JPrintWriter) private def importsCommand(line: String): Result = { val tokens = words(line) val handlers = intp.languageWildcardHandlers ++ intp.importHandlers - val isVerbose = tokens contains "-v" handlers.filterNot(_.importedSymbols.isEmpty).zipWithIndex foreach { case (handler, idx) => diff --git a/src/compiler/scala/tools/nsc/interpreter/IMain.scala b/src/compiler/scala/tools/nsc/interpreter/IMain.scala index a44f862dd7..7e2dbef9ec 100644 --- a/src/compiler/scala/tools/nsc/interpreter/IMain.scala +++ b/src/compiler/scala/tools/nsc/interpreter/IMain.scala @@ -69,9 +69,8 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends @deprecated("Use replOutput.dir instead", "2.11.0") def virtualDirectory = replOutput.dir - def showDirectory = replOutput.show(out) + def showDirectory() = replOutput.show(out) - private var currentSettings: Settings = initialSettings private[nsc] var printResults = true // whether to print result lines private[nsc] var totalSilence = false // whether to print anything private var _initializeComplete = false // compiler is initialized @@ -98,7 +97,7 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends if (isInitializeComplete) global.classPath.asURLs else new PathResolver(settings).result.asURLs // the compiler's classpath ) - def settings = currentSettings + def settings = initialSettings def mostRecentLine = prevRequestList match { case Nil => "" case req :: _ => req.originalLine @@ -592,7 +591,7 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends */ def bind(name: String, boundType: String, value: Any, modifiers: List[String] = Nil): IR.Result = { val bindRep = new ReadEvalPrint() - val run = bindRep.compile(""" + bindRep.compile(""" |object %s { | var value: %s = _ | def set(x: Any) = value = x.asInstanceOf[%s] @@ -622,7 +621,6 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends def rebind(p: NamedParam): IR.Result = { val name = p.name - val oldType = typeOfTerm(name) orElse { return IR.Error } val newType = p.tpe val tempName = freshInternalVarName() diff --git a/src/compiler/scala/tools/nsc/javac/JavaParsers.scala b/src/compiler/scala/tools/nsc/javac/JavaParsers.scala index a30ae1cb36..8d70ac7c4a 100644 --- a/src/compiler/scala/tools/nsc/javac/JavaParsers.scala +++ b/src/compiler/scala/tools/nsc/javac/JavaParsers.scala @@ -348,8 +348,7 @@ trait JavaParsers extends ast.parser.ParsersCommon with JavaScanners { /** Annotation ::= TypeName [`(` AnnotationArgument {`,` AnnotationArgument} `)`] */ def annotation() { - val pos = in.currentPos - var t = qualId() + qualId() if (in.token == LPAREN) { skipAhead(); accept(RPAREN) } else if (in.token == LBRACE) { skipAhead(); accept(RBRACE) } } diff --git a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala index 369b6aa77d..a5acf5734c 100644 --- a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala +++ b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala @@ -226,7 +226,6 @@ abstract class SymbolLoaders { assert(root.isPackageClass, root) root.setInfo(new PackageClassInfoType(newScope, root)) - val sourcepaths = classpath.sourcepaths if (!root.isRoot) { for (classRep <- classpath.classes if platform.doLoad(classRep)) { initializeFromClassPath(root, classRep) diff --git a/src/compiler/scala/tools/nsc/symtab/SymbolTrackers.scala b/src/compiler/scala/tools/nsc/symtab/SymbolTrackers.scala index 249f6151ef..d2d97ceacf 100644 --- a/src/compiler/scala/tools/nsc/symtab/SymbolTrackers.scala +++ b/src/compiler/scala/tools/nsc/symtab/SymbolTrackers.scala @@ -110,7 +110,6 @@ trait SymbolTrackers { case Some(oldFlags) => val added = masked & ~oldFlags val removed = oldFlags & ~masked - val steady = masked & ~(added | removed) val all = masked | oldFlags val strs = 0 to 63 map { bit => val flag = 1L << bit @@ -177,7 +176,7 @@ trait SymbolTrackers { } def show(label: String): String = { val hierarchy = Node(current) - val Change(added, removed, symMap, owners, flags) = history.head + val Change(_, removed, symMap, _, _) = history.head def detailString(sym: Symbol) = { val ownerString = sym.ownerChain splitAt 3 match { case (front, back) => diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala index 42589874fe..5922d67a94 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala @@ -497,8 +497,8 @@ abstract class ClassfileParser { def parseClass() { val jflags = in.nextChar val isAnnotation = hasAnnotation(jflags) - var sflags = toScalaClassFlags(jflags) - var nameIdx = in.nextChar + val sflags = toScalaClassFlags(jflags) + val nameIdx = in.nextChar currentClass = pool.getClassName(nameIdx) /** Parse parents for Java classes. For Scala, return AnyRef, since the real type will be unpickled. @@ -596,7 +596,7 @@ abstract class ClassfileParser { def parseField() { val jflags = in.nextChar - var sflags = toScalaFieldFlags(jflags) + val sflags = toScalaFieldFlags(jflags) if ((sflags & PRIVATE) != 0L && !global.settings.optimise.value) { in.skip(4); skipAttributes() } else { @@ -626,7 +626,7 @@ abstract class ClassfileParser { def parseMethod() { val jflags = in.nextChar.toInt - var sflags = toScalaMethodFlags(jflags) + val sflags = toScalaMethodFlags(jflags) if (isPrivate(jflags) && !global.settings.optimise.value) { val name = pool.getName(in.nextChar) if (name == nme.CONSTRUCTOR) @@ -1078,7 +1078,7 @@ abstract class ClassfileParser { def enterClassAndModule(entry: InnerClassEntry, file: AbstractFile, jflags: Int) { val completer = new global.loaders.ClassfileLoader(file) val name = entry.originalName - var sflags = toScalaClassFlags(jflags) + val sflags = toScalaClassFlags(jflags) val owner = getOwner(jflags) val scope = getScope(jflags) val innerClass = owner.newClass(name.toTypeName, NoPosition, sflags) setInfo completer diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala index b286f52280..5af6786002 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala @@ -33,7 +33,6 @@ abstract class ICodeReader extends ClassfileParser { * for non-static members. */ def readClass(cls: Symbol): (IClass, IClass) = { - var classFile: io.AbstractFile = null; cls.info // ensure accurate type information isScalaModule = cls.isModule && !cls.isJavaDefined @@ -58,11 +57,9 @@ abstract class ICodeReader extends ClassfileParser { override def parseClass() { this.instanceCode = new IClass(clazz) this.staticCode = new IClass(staticModule) - val jflags = in.nextChar - val isAttribute = (jflags & JAVA_ACC_ANNOTATION) != 0 - val sflags = toScalaClassFlags(jflags) // what, this is never used?? - val c = pool getClassSymbol in.nextChar + in.nextChar + pool getClassSymbol in.nextChar parseInnerClasses() in.skip(2) // super class @@ -125,7 +122,7 @@ abstract class ICodeReader extends ClassfileParser { override def parseMethod() { val (jflags, sym) = parseMember(false) - var beginning = in.bp + val beginning = in.bp try { if (sym != NoSymbol) { this.method = new IMethod(sym) @@ -669,7 +666,6 @@ abstract class ICodeReader extends ClassfileParser { val blocks = makeBasicBlocks var otherBlock: BasicBlock = NoBasicBlock - var disableJmpTarget = false for ((pc, instr) <- instrs.iterator) { // Console.println("> " + pc + ": " + instr); @@ -724,7 +720,6 @@ abstract class ICodeReader extends ClassfileParser { /** Abstract interpretation for one instruction. */ override def mutatingInterpret(out: typeFlowLattice.Elem, i: Instruction): typeFlowLattice.Elem = { - val bindings = out.vars val stack = out.stack import stack.push i match { diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala index 7c82895677..de12428c7c 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala @@ -425,7 +425,7 @@ abstract class Pickler extends SubComponent { * argument of some Annotation */ private def putMods(mods: Modifiers) = if (putEntry(mods)) { // annotations in Modifiers are removed by the typechecker - val Modifiers(flags, privateWithin, Nil) = mods + val Modifiers(_, privateWithin, Nil) = mods putEntry(privateWithin) } @@ -998,7 +998,6 @@ abstract class Pickler extends SubComponent { } def printRefs(refs: List[AnyRef]) { refs foreach printRef } def printSymInfo(sym: Symbol) { - var posOffset = 0 printRef(sym.name) printRef(localizedOwner(sym)) print(flagsToString(sym.flags & PickledFlags)+" ") diff --git a/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala b/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala index 1d2ffd2a73..99dec8e3f7 100644 --- a/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala +++ b/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala @@ -520,12 +520,12 @@ abstract class TypeParser { val delegateParamTypes: List[Type] = List(typClrType); // not ImplicitMethodType, this is for methods with implicit parameters (not implicit methods) val forwardViewMethodType = (msym: Symbol) => JavaMethodType(msym.newSyntheticValueParams(delegateParamTypes), funType) - val fmsym = createMethod(nme.view_, flags, forwardViewMethodType, null, true); + createMethod(nme.view_, flags, forwardViewMethodType, null, true); // create the backward view: function => delegate val functionParamTypes: List[Type] = List(funType); val backwardViewMethodType = (msym: Symbol) => JavaMethodType(msym.newSyntheticValueParams(functionParamTypes), typClrType) - val bmsym = createMethod(nme.view_, flags, backwardViewMethodType, null, true); + createMethod(nme.view_, flags, backwardViewMethodType, null, true); } private def createDelegateChainers(typ: MSILType) = { diff --git a/src/compiler/scala/tools/nsc/transform/CleanUp.scala b/src/compiler/scala/tools/nsc/transform/CleanUp.scala index 1f353bb31c..2e504af47f 100644 --- a/src/compiler/scala/tools/nsc/transform/CleanUp.scala +++ b/src/compiler/scala/tools/nsc/transform/CleanUp.scala @@ -45,7 +45,7 @@ abstract class CleanUp extends Transform with ast.TreeDSL { result } private def transformTemplate(tree: Tree) = { - val Template(parents, self, body) = tree + val Template(_, _, body) = tree clearStatics() val newBody = transformTrees(body) val templ = deriveTemplate(tree)(_ => transformTrees(newStaticMembers.toList) ::: newBody) diff --git a/src/compiler/scala/tools/nsc/transform/Constructors.scala b/src/compiler/scala/tools/nsc/transform/Constructors.scala index 1db3db9376..b8c14c2733 100644 --- a/src/compiler/scala/tools/nsc/transform/Constructors.scala +++ b/src/compiler/scala/tools/nsc/transform/Constructors.scala @@ -422,7 +422,7 @@ abstract class Constructors extends Transform with ast.TreeDSL { def ensureAccessor(sym: Symbol)(acc: => Symbol) = if (sym.owner == clazz && !sym.isMethod && sym.isPrivate) { // there's an access to a naked field of the enclosing class - var getr = acc + val getr = acc getr makeNotPrivate clazz getr } else { @@ -529,7 +529,8 @@ abstract class Constructors extends Transform with ast.TreeDSL { (pre ::: supercalls, rest) } - var (uptoSuperStats, remainingConstrStats) = splitAtSuper(constrStatBuf.toList) + val (uptoSuperStats, remainingConstrStats0) = splitAtSuper(constrStatBuf.toList) + var remainingConstrStats = remainingConstrStats0 /** XXX This is not corect: remainingConstrStats.nonEmpty excludes too much, * but excluding it includes too much. The constructor sequence being mimicked diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index 7d7e53b946..7c77d7e27e 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -724,15 +724,7 @@ abstract class Erasure extends AddInterfaces case Apply(TypeApply(sel @ Select(qual, name), List(targ)), List()) if tree.symbol == Any_asInstanceOf => val qual1 = typedQualifier(qual, NOmode, ObjectClass.tpe) // need to have an expected type, see #3037 - val qualClass = qual1.tpe.typeSymbol -/* - val targClass = targ.tpe.typeSymbol - if (isNumericValueClass(qualClass) && isNumericValueClass(targClass)) - // convert numeric type casts - atPos(tree.pos)(Apply(Select(qual1, "to" + targClass.name), List())) - else -*/ if (isPrimitiveValueType(targ.tpe) || isErasedValueType(targ.tpe)) { val noNullCheckNeeded = targ.tpe match { case ErasedValueType(tref) => diff --git a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala index 4a0d25fd09..cfd1063f40 100644 --- a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala +++ b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala @@ -335,7 +335,7 @@ abstract class ExplicitOuter extends InfoTransform */ def outerAccessorDef: Tree = { val outerAcc = outerAccessor(currentClass) - var rhs: Tree = + val rhs: Tree = if (outerAcc.isDeferred) EmptyTree else This(currentClass) DOT outerField(currentClass) diff --git a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala index bd1649dec5..2a25cc37a0 100644 --- a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala @@ -157,7 +157,6 @@ trait ContextErrors { case RefinedType(parents, decls) if !decls.isEmpty && found.typeSymbol.isAnonOrRefinementClass => val retyped = typed (tree.duplicate setType null) val foundDecls = retyped.tpe.decls filter (sym => !sym.isConstructor && !sym.isSynthetic) - if (foundDecls.isEmpty || (found.typeSymbol eq NoSymbol)) found else { // The members arrive marked private, presumably because there was no @@ -171,11 +170,11 @@ trait ContextErrors { case _ => found } - assert(!found.isErroneous && !req.isErroneous, (found, req)) + assert(!foundType.isErroneous && !req.isErroneous, (foundType, req)) - issueNormalTypeError(tree, withAddendum(tree.pos)(typeErrorMsg(found, req, infer.isPossiblyMissingArgs(found, req))) ) + issueNormalTypeError(tree, withAddendum(tree.pos)(typeErrorMsg(foundType, req, infer.isPossiblyMissingArgs(foundType, req))) ) if (settings.explaintypes.value) - explainTypes(found, req) + explainTypes(foundType, req) } def WithFilterError(tree: Tree, ex: AbsTypeError) = { @@ -673,7 +672,6 @@ trait ContextErrors { private def macroExpansionError(expandee: Tree, msg: String, pos: Position = NoPosition) = { def msgForLog = if (msg != null && (msg contains "exception during macro expansion")) msg.split(EOL).drop(1).headOption.getOrElse("?") else msg macroLogLite("macro expansion has failed: %s".format(msgForLog)) - val errorPos = if (pos != NoPosition) pos else (if (expandee.pos != NoPosition) expandee.pos else enclosingMacroPosition) if (msg != null) context.error(pos, msg) // issueTypeError(PosAndMsgTypeError(..)) won't work => swallows positions setError(expandee) throw MacroExpansionException diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala index 5a9a4caea1..73efceb242 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala @@ -664,10 +664,6 @@ trait Implicits { // duplicating the code here, but this is probably a // hotspot (and you can't just call typed, need to force // re-typecheck) - // TODO: the return tree is ignored. This seems to make - // no difference, but it's bad practice regardless. - - val checked = itree2 match { case TypeApply(fun, args) => typedTypeApply(itree2, EXPRmode, fun, args) case Apply(TypeApply(fun, args), _) => typedTypeApply(itree2, EXPRmode, fun, args) // t2421c @@ -677,7 +673,7 @@ trait Implicits { if (context.hasErrors) fail("typing TypeApply reported errors for the implicit tree: " + context.errBuffer.head.errMsg) else { - val result = new SearchResult(itree2, subst) + val result = new SearchResult(checked, subst) if (Statistics.canEnable) Statistics.incCounter(foundImplicits) printInference("[success] found %s for pt %s".format(result, ptInstantiated)) result @@ -1205,7 +1201,7 @@ trait Implicits { } ) // todo. migrate hardcoded materialization in Implicits to corresponding implicit macros - var materializer = atPos(pos.focus)(gen.mkMethodCall(TagMaterializers(tagClass), List(tp), if (prefix != EmptyTree) List(prefix) else List())) + val materializer = atPos(pos.focus)(gen.mkMethodCall(TagMaterializers(tagClass), List(tp), if (prefix != EmptyTree) List(prefix) else List())) if (settings.XlogImplicits.value) println("materializing requested %s.%s[%s] using %s".format(pre, tagClass.name, tp, materializer)) if (context.macrosEnabled) success(materializer) // don't call `failure` here. if macros are disabled, we just fail silently diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index 61e4fb86a2..b96daa49e2 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -312,7 +312,6 @@ trait Infer extends Checkable { if (sym.isError) { tree setSymbol sym setType ErrorType } else { - val topClass = context.owner.enclosingTopLevelClass if (context.unit.exists) context.unit.depends += sym.enclosingTopLevelClass diff --git a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala index c95951e608..049348b0b8 100644 --- a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala +++ b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala @@ -556,7 +556,7 @@ trait MethodSynthesis { // No Symbols available. private def beanAccessorsFromNames(tree: ValDef) = { - val ValDef(mods, name, tpt, _) = tree + val ValDef(mods, _, _, _) = tree val hasBP = mods hasAnnotationNamed tpnme.BeanPropertyAnnot val hasBoolBP = mods hasAnnotationNamed tpnme.BooleanBeanPropertyAnnot diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index 99b927af66..5e537e3bb3 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -337,7 +337,6 @@ trait Namers extends MethodSynthesis { } private def enterClassSymbol(tree: ClassDef, clazz: ClassSymbol): Symbol = { - val file = contextFile if (clazz.sourceFile != null && clazz.sourceFile != contextFile) debugwarn("!!! Source mismatch in " + clazz + ": " + clazz.sourceFile + " vs. " + contextFile) @@ -643,7 +642,7 @@ trait Namers extends MethodSynthesis { } def enterClassDef(tree: ClassDef) { - val ClassDef(mods, name, tparams, impl) = tree + val ClassDef(mods, _, _, impl) = tree val primaryConstructorArity = treeInfo.firstConstructorArgs(impl.body).size tree.symbol = enterClassSymbol(tree) tree.symbol setInfo completerOf(tree) @@ -1200,9 +1199,9 @@ trait Namers extends MethodSynthesis { // same local block several times (which can happen in interactive mode) we might // otherwise not find the default symbol, because the second time it the method // symbol will be re-entered in the scope but the default parameter will not. - val att = meth.attachments.get[DefaultsOfLocalMethodAttachment] match { + meth.attachments.get[DefaultsOfLocalMethodAttachment] match { case Some(att) => att.defaultGetters += default - case None => meth.updateAttachment(new DefaultsOfLocalMethodAttachment(default)) + case None => meth.updateAttachment(new DefaultsOfLocalMethodAttachment(default)) } } } else if (baseHasDefault) { diff --git a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala index 74acaba74a..f097aa6424 100644 --- a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala +++ b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala @@ -171,7 +171,7 @@ trait NamesDefaults { self: Analyzer => qual changeOwner (blockTyper.context.owner -> sym) val newQual = atPos(qual.pos.focus)(blockTyper.typedQualifier(Ident(sym.name))) - var baseFunTransformed = atPos(baseFun.pos.makeTransparent) { + val baseFunTransformed = atPos(baseFun.pos.makeTransparent) { // setSymbol below is important because the 'selected' function might be overloaded. by // assigning the correct method symbol, typedSelect will just assign the type. the reason // to still call 'typed' is to correctly infer singleton types, SI-5259. @@ -319,7 +319,7 @@ trait NamesDefaults { self: Analyzer => assert(isNamedApplyBlock(transformedFun), transformedFun) val NamedApplyInfo(qual, targs, vargss, blockTyper) = context.namedApplyBlockInfo.get._2 - val existingBlock @ Block(stats, funOnly) = transformedFun + val Block(stats, funOnly) = transformedFun // type the application without names; put the arguments in definition-site order val typedApp = doTypedApply(tree, funOnly, reorderArgs(namelessArgs, argPos), mode, pt) diff --git a/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala b/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala index 3f0a4d1548..60cd21cbf1 100644 --- a/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala +++ b/src/compiler/scala/tools/nsc/typechecker/PatternMatching.scala @@ -1818,9 +1818,9 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL def toString(x: AnyRef) = if (x eq null) "" else x.toString if (cols.isEmpty || cols.tails.isEmpty) cols map toString else { - val (colStrs, colLens) = cols map {c => val s = toString(c); (s, s.length)} unzip - val maxLen = max(colLens) - val avgLen = colLens.sum/colLens.length + val colLens = cols map (c => toString(c).length) + val maxLen = max(colLens) + val avgLen = colLens.sum/colLens.length val goalLen = maxLen min avgLen*2 def pad(s: String) = { val toAdd = ((goalLen - s.length) max 0) + 2 @@ -2263,9 +2263,9 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL private[this] val id: Int = Var.nextId // private[this] var canModify: Option[Array[StackTraceElement]] = None - private[this] def ensureCanModify = {} //if (canModify.nonEmpty) patmatDebug("BUG!"+ this +" modified after having been observed: "+ canModify.get.mkString("\n")) + private[this] def ensureCanModify() = {} //if (canModify.nonEmpty) patmatDebug("BUG!"+ this +" modified after having been observed: "+ canModify.get.mkString("\n")) - private[this] def observed = {} //canModify = Some(Thread.currentThread.getStackTrace) + private[this] def observed() = {} //canModify = Some(Thread.currentThread.getStackTrace) // don't access until all potential equalities have been registered using registerEquality private[this] val symForEqualsTo = new scala.collection.mutable.HashMap[Const, Sym] @@ -2418,7 +2418,13 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL private lazy val equalitySyms = {observed; symForEqualsTo.values.toList} // don't call until all equalities have been registered and registerNull has been called (if needed) - def describe = toString + ": " + staticTp + domain.map(_.mkString(" ::= ", " | ", "// "+ symForEqualsTo.keys)).getOrElse(symForEqualsTo.keys.mkString(" ::= ", " | ", " | ...")) + " // = " + path + def describe = { + def domain_s = domain match { + case Some(d) => d mkString (" ::= ", " | ", "// "+ symForEqualsTo.keys) + case _ => symForEqualsTo.keys mkString (" ::= ", " | ", " | ...") + } + s"$this: ${staticTp}${domain_s} // = $path" + } override def toString = "V"+ id } @@ -2504,7 +2510,7 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL // corresponds to a type test that does not imply any value-equality (well, except for outer checks, which we don't model yet) sealed class TypeConst(val tp: Type) extends Const { assert(!(tp =:= NullTp)) - private[this] val id: Int = Const.nextTypeId + /*private[this] val id: Int = */ Const.nextTypeId val wideTp = widenToClass(tp) def isValue = false @@ -2552,7 +2558,7 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL sealed class ValueConst(val tp: Type, val wideTp: Type, override val toString: String) extends Const { // patmatDebug("VC"+(tp, wideTp, toString)) assert(!(tp =:= NullTp)) // TODO: assert(!tp.isStable) - private[this] val id: Int = Const.nextValueId + /*private[this] val id: Int = */Const.nextValueId def isValue = true } @@ -2778,7 +2784,6 @@ trait PatternMatching extends Transform with TypingTransformers with ast.TreeDSL // when does the match fail? val matchFails = Not(\/(symbolicCases)) - val vars = gatherVariables(matchFails) // debug output: patmatDebug("analysing:") diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index c04a8661b2..5b2fbb4fd0 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -237,7 +237,7 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans case class MixinOverrideError(member: Symbol, msg: String) - var mixinOverrideErrors = new ListBuffer[MixinOverrideError]() + val mixinOverrideErrors = new ListBuffer[MixinOverrideError]() def printMixinOverrideErrors() { mixinOverrideErrors.toList match { @@ -1217,7 +1217,7 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans /* Convert a reference to a case factory of type `tpe` to a new of the class it produces. */ def toConstructor(pos: Position, tpe: Type): Tree = { - var rtpe = tpe.finalResultType + val rtpe = tpe.finalResultType assert(rtpe.typeSymbol hasFlag CASE, tpe); localTyper.typedOperator { atPos(pos) { @@ -1298,7 +1298,7 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans } case ModuleDef(_, _, _) => eliminateModuleDefs(tree) case ValDef(_, _, _, _) => - val tree1 @ ValDef(_, _, _, rhs) = transform(tree) // important to do before forward reference check + val tree1 = transform(tree) // important to do before forward reference check if (tree1.symbol.isLazy) tree1 :: Nil else { val lazySym = tree.symbol.lazyAccessorOrSelf @@ -1540,7 +1540,7 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans tree } private def transformSelect(tree: Select): Tree = { - val Select(qual, name) = tree + val Select(qual, _) = tree val sym = tree.symbol /** Note: if a symbol has both @deprecated and @migration annotations and both diff --git a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala index b8b34ce738..90d265d7b3 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala @@ -390,7 +390,7 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT * typed. */ private def makeAccessor(tree: Select, targs: List[Tree]): Tree = { - val Select(qual, name) = tree + val Select(qual, _) = tree val sym = tree.symbol val clazz = hostForAccessorOf(sym, currentClass) diff --git a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala index 4bcdb177ae..f7cd89144a 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala @@ -109,9 +109,6 @@ trait SyntheticMethods extends ast.TreeDSL { gen.mkMethodCall(ScalaRunTimeModule, nme.typedProductIterator, List(accessorLub), List(mkThis)) ) } - def projectionMethod(accessor: Symbol, num: Int) = { - createMethod(nme.productAccessorName(num), accessor.tpe.resultType)(_ => REF(accessor)) - } /** Common code for productElement and (currently disabled) productElementName */ @@ -203,10 +200,15 @@ trait SyntheticMethods extends ast.TreeDSL { /** The _1, _2, etc. methods to implement ProductN, disabled * until we figure out how to introduce ProductN without cycles. */ - def productNMethods = { + /**** + def productNMethods = { val accs = accessors.toIndexedSeq 1 to arity map (num => productProj(arity, num) -> (() => projectionMethod(accs(num - 1), num))) } + def projectionMethod(accessor: Symbol, num: Int) = { + createMethod(nme.productAccessorName(num), accessor.tpe.resultType)(_ => REF(accessor)) + } + ****/ // methods for both classes and objects def productMethods = { @@ -327,7 +329,6 @@ trait SyntheticMethods extends ast.TreeDSL { def isRewrite(sym: Symbol) = sym.isCaseAccessorMethod && !sym.isPublic for (ddef @ DefDef(_, _, _, _, _, _) <- templ.body ; if isRewrite(ddef.symbol)) { - val original = ddef.symbol val newAcc = deriveMethod(ddef.symbol, name => context.unit.freshTermName(name + "$")) { newAcc => newAcc.makePublic newAcc resetFlag (ACCESSOR | PARAMACCESSOR) diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index c798e38e92..3d80df405d 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -1197,9 +1197,9 @@ trait Typers extends Modes with Adaptations with Tags { val found = tree.tpe if (!found.isErroneous && !pt.isErroneous) { if ((!context.reportErrors && isPastTyper) || tree.attachments.get[MacroExpansionAttachment].isDefined) { - val (bound, req) = pt match { - case ExistentialType(qs, tpe) => (qs, tpe) - case _ => (Nil, pt) + val bound = pt match { + case ExistentialType(qs, _) => qs + case _ => Nil } val boundOrSkolems = bound ++ pt.skolemsExceptMethodTypeParams if (boundOrSkolems.nonEmpty) { @@ -1519,7 +1519,6 @@ trait Typers extends Modes with Adaptations with Tags { val (stats, rest) = cstats span (x => !treeInfo.isSuperConstrCall(x)) (stats map (_.duplicate), if (rest.isEmpty) EmptyTree else rest.head.duplicate) } - val cstats1 = if (superCall == EmptyTree) preSuperStats else preSuperStats :+ superCall val cbody1 = treeCopy.Block(cbody, preSuperStats, superCall match { case Apply(_, _) if supertparams.nonEmpty => transformSuperCall(superCall) case _ => cunit.duplicate @@ -1805,7 +1804,7 @@ trait Typers extends Modes with Adaptations with Tags { def typedTemplate(templ: Template, parents1: List[Tree]): Template = { val clazz = context.owner // complete lazy annotations - val annots = clazz.annotations + clazz.annotations if (templ.symbol == NoSymbol) templ setSymbol clazz.newLocalDummy(templ.pos) val self1 = templ.self match { @@ -1886,8 +1885,8 @@ trait Typers extends Modes with Adaptations with Tags { val typedMods = typedModifiers(vdef.mods) // complete lazy annotations - val annots = sym.annotations - var tpt1 = checkNoEscaping.privates(sym, typer1.typedType(vdef.tpt)) + sym.annotations + val tpt1 = checkNoEscaping.privates(sym, typer1.typedType(vdef.tpt)) checkNonCyclic(vdef, tpt1) if (sym.hasAnnotation(definitions.VolatileAttr) && !sym.isMutable) @@ -2123,13 +2122,13 @@ trait Typers extends Modes with Adaptations with Tags { val vparamss1 = ddef.vparamss mapConserve (_ mapConserve typedValDef) // complete lazy annotations - val annots = meth.annotations + meth.annotations for (vparams1 <- vparamss1; vparam1 <- vparams1 dropRight 1) if (isRepeatedParamType(vparam1.symbol.tpe)) StarParamNotLastError(vparam1) - var tpt1 = checkNoEscaping.privates(meth, typedType(ddef.tpt)) + val tpt1 = checkNoEscaping.privates(meth, typedType(ddef.tpt)) checkNonCyclic(ddef, tpt1) ddef.tpt.setType(tpt1.tpe) val typedMods = typedModifiers(ddef.mods) @@ -2199,7 +2198,7 @@ trait Typers extends Modes with Adaptations with Tags { val tparams1 = tdef.tparams mapConserve typedTypeDef val typedMods = typedModifiers(tdef.mods) // complete lazy annotations - val annots = tdef.symbol.annotations + tdef.symbol.annotations // @specialized should not be pickled when compiling with -no-specialize if (settings.nospecialization.value && currentRun.compiles(tdef.symbol)) { @@ -3744,11 +3743,11 @@ trait Typers extends Modes with Adaptations with Tags { if (wc.symbol == NoSymbol) { namer.enterSym(wc); wc.symbol setFlag EXISTENTIAL } else context.scope enter wc.symbol val whereClauses1 = typedStats(tree.whereClauses, context.owner) - for (vd @ ValDef(_, _, _, _) <- tree.whereClauses) + for (vd @ ValDef(_, _, _, _) <- whereClauses1) if (vd.symbol.tpe.isVolatile) AbstractionFromVolatileTypeError(vd) val tpt1 = typedType(tree.tpt, mode) - existentialTransform(tree.whereClauses map (_.symbol), tpt1.tpe)((tparams, tp) => + existentialTransform(whereClauses1 map (_.symbol), tpt1.tpe)((tparams, tp) => TypeTree(newExistentialType(tparams, tp)) setOriginal tree ) } @@ -4775,7 +4774,8 @@ trait Typers extends Modes with Adaptations with Tags { * (2) Change imported symbols to selections */ def typedIdent(tree: Tree, name: Name): Tree = { - def emptyPackageOk = settings.exposeEmptyPackage.value // setting to enable unqualified idents in empty package + // setting to enable unqualified idents in empty package + def inEmptyPackage = if (settings.exposeEmptyPackage.value) lookupInEmpty(name) else NoSymbol def issue(err: AbsTypeError) = { // Avoiding some spurious error messages: see SI-2388. @@ -4791,17 +4791,15 @@ trait Typers extends Modes with Adaptations with Tags { case NoSymbol => startContext.lookupSymbol(name, qualifies) case sym => LookupSucceeded(EmptyTree, sym) } - val defSym = ( - nameLookup.symbol - orElse ( if (emptyPackageOk) lookupInEmpty(name) else NoSymbol ) - orElse (lookupInRoot(name) andAlso (sym => return typed1(tree setSymbol sym, mode, pt))) - orElse (context.owner newErrorSymbol name) - ) import InferErrorGen._ nameLookup match { case LookupAmbiguous(msg) => issue(AmbiguousIdentError(tree, name, msg)) case LookupInaccessible(sym, msg) => issue(AccessError(tree, sym, context, msg)) - case LookupNotFound => issue(SymbolNotFoundError(tree, name, context.owner, startContext)) + case LookupNotFound => + inEmptyPackage orElse lookupInRoot(name) match { + case NoSymbol => issue(SymbolNotFoundError(tree, name, context.owner, startContext)) + case sym => typed1(tree setSymbol sym, mode, pt) + } case LookupSucceeded(qual, sym) => // this -> Foo.this if (sym.isThisSym) @@ -4905,7 +4903,7 @@ trait Typers extends Modes with Adaptations with Tags { val pid1 = typedQualifier(pdef.pid).asInstanceOf[RefTree] assert(sym.moduleClass ne NoSymbol, sym) // complete lazy annotations - val annots = sym.annotations + sym.annotations val stats1 = newTyper(context.make(tree, sym.moduleClass, sym.info.decls)) .typedStats(pdef.stats, NoSymbol) treeCopy.PackageDef(tree, pid1, stats1) setType NoType @@ -5225,7 +5223,7 @@ trait Typers extends Modes with Adaptations with Tags { } alreadyTyped = tree.tpe ne null - var tree1: Tree = if (alreadyTyped) tree else { + val tree1: Tree = if (alreadyTyped) tree else { printTyping( ptLine("typing %s: pt = %s".format(ptTree(tree), pt), "undetparams" -> context.undetparams, diff --git a/src/compiler/scala/tools/reflect/ToolBoxFactory.scala b/src/compiler/scala/tools/reflect/ToolBoxFactory.scala index bc8ded62d8..996ff00d36 100644 --- a/src/compiler/scala/tools/reflect/ToolBoxFactory.scala +++ b/src/compiler/scala/tools/reflect/ToolBoxFactory.scala @@ -29,8 +29,8 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf => lazy val classLoader = new AbstractFileClassLoader(virtualDirectory, factorySelf.mirror.classLoader) lazy val mirror: u.Mirror = u.runtimeMirror(classLoader) - class ToolBoxGlobal(settings: scala.tools.nsc.Settings, reporter: Reporter) - extends ReflectGlobal(settings, reporter, toolBoxSelf.classLoader) { + class ToolBoxGlobal(settings: scala.tools.nsc.Settings, reporter0: Reporter) + extends ReflectGlobal(settings, reporter0, toolBoxSelf.classLoader) { import definitions._ private val trace = scala.tools.nsc.util.trace when settings.debug.value @@ -73,13 +73,14 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf => val typed = expr filter (t => t.tpe != null && t.tpe != NoType && !t.isInstanceOf[TypeTree]) if (!typed.isEmpty) throw ToolBoxError("reflective toolbox has failed: cannot operate on trees that are already typed") - val freeTypes = expr.freeTypes - if (freeTypes.length > 0) { - var msg = "reflective toolbox has failed:" + EOL - msg += "unresolved free type variables (namely: " + (freeTypes map (ft => "%s %s".format(ft.name, ft.origin)) mkString ", ") + "). " - msg += "have you forgot to use TypeTag annotations for type parameters external to a reifee? " - msg += "if you have troubles tracking free type variables, consider using -Xlog-free-types" - throw ToolBoxError(msg) + if (expr.freeTypes.nonEmpty) { + val ft_s = expr.freeTypes map (ft => s" ${ft.name} ${ft.origin}") mkString "\n " + throw ToolBoxError(s""" + |reflective toolbox failed due to unresolved free type variables: + |$ft_s + |have you forgotten to use TypeTag annotations for type parameters external to a reifee? + |if you have troubles tracking free type variables, consider using -Xlog-free-types + """.stripMargin.trim) } } @@ -100,7 +101,7 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf => if (namesakes.length > 0) name += ("$" + (namesakes.length + 1)) freeTermNames += (ft -> newTermName(name + nme.REIFY_FREE_VALUE_SUFFIX)) }) - var expr = new Transformer { + val expr = new Transformer { override def transform(tree: Tree): Tree = if (tree.hasSymbolField && tree.symbol.isFreeTerm) { tree match { @@ -132,7 +133,7 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf => val ownerClass = rootMirror.EmptyPackageClass.newClassSymbol(newTypeName("<expression-owner>")) build.setTypeSignature(ownerClass, ClassInfoType(List(ObjectClass.tpe), newScope, ownerClass)) val owner = ownerClass.newLocalDummy(expr.pos) - var currentTyper = analyzer.newTyper(analyzer.rootContext(NoCompilationUnit, EmptyTree).make(expr, owner)) + val currentTyper = analyzer.newTyper(analyzer.rootContext(NoCompilationUnit, EmptyTree).make(expr, owner)) val wrapper1 = if (!withImplicitViewsDisabled) (currentTyper.context.withImplicitsEnabled[Tree] _) else (currentTyper.context.withImplicitsDisabled[Tree] _) val wrapper2 = if (!withMacrosDisabled) (currentTyper.context.withMacrosEnabled[Tree] _) else (currentTyper.context.withMacrosDisabled[Tree] _) def wrapper (tree: => Tree) = wrapper1(wrapper2(tree)) @@ -146,7 +147,7 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf => case Block(dummies, unwrapped) => (dummies, unwrapped) case unwrapped => (Nil, unwrapped) } - var invertedIndex = freeTerms map (_.swap) + val invertedIndex = freeTerms map (_.swap) // todo. also fixup singleton types unwrapped = new Transformer { override def transform(tree: Tree): Tree = @@ -202,7 +203,7 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf => def wrap(expr0: Tree): ModuleDef = { val (expr, freeTerms) = extractFreeTerms(expr0, wrapFreeTermRefs = true) - val (obj, mclazz) = rootMirror.EmptyPackageClass.newModuleAndClassSymbol( + val (obj, _) = rootMirror.EmptyPackageClass.newModuleAndClassSymbol( nextWrapperModuleName()) val minfo = ClassInfoType(List(ObjectClass.tpe), newScope, obj.moduleClass) @@ -235,7 +236,7 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf => NoPosition)) trace("wrapped: ")(showAttributed(moduledef, true, true, settings.Yshowsymkinds.value)) - var cleanedUp = resetLocalAttrs(moduledef) + val cleanedUp = resetLocalAttrs(moduledef) trace("cleaned up: ")(showAttributed(cleanedUp, true, true, settings.Yshowsymkinds.value)) cleanedUp.asInstanceOf[ModuleDef] } @@ -353,8 +354,8 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf => def typeCheck(tree: u.Tree, expectedType: u.Type, silent: Boolean = false, withImplicitViewsDisabled: Boolean = false, withMacrosDisabled: Boolean = false): u.Tree = compiler.withCleanupCaches { if (compiler.settings.verbose.value) println("importing "+tree+", expectedType = "+expectedType) - var ctree: compiler.Tree = importer.importTree(tree) - var cexpectedType: compiler.Type = importer.importType(expectedType) + val ctree: compiler.Tree = importer.importTree(tree) + val cexpectedType: compiler.Type = importer.importType(expectedType) if (compiler.settings.verbose.value) println("typing "+ctree+", expectedType = "+expectedType) val ttree: compiler.Tree = compiler.typeCheck(ctree, cexpectedType, silent = silent, withImplicitViewsDisabled = withImplicitViewsDisabled, withMacrosDisabled = withMacrosDisabled) @@ -373,9 +374,9 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf => private def inferImplicit(tree: u.Tree, pt: u.Type, isView: Boolean, silent: Boolean, withMacrosDisabled: Boolean, pos: u.Position): u.Tree = compiler.withCleanupCaches { if (compiler.settings.verbose.value) println("importing "+pt, ", tree = "+tree+", pos = "+pos) - var ctree: compiler.Tree = importer.importTree(tree) - var cpt: compiler.Type = importer.importType(pt) - var cpos: compiler.Position = importer.importPosition(pos) + val ctree: compiler.Tree = importer.importTree(tree) + val cpt: compiler.Type = importer.importType(pt) + val cpos: compiler.Position = importer.importPosition(pos) if (compiler.settings.verbose.value) println("inferring implicit %s of type %s, macros = %s".format(if (isView) "view" else "value", pt, !withMacrosDisabled)) val itree: compiler.Tree = compiler.inferImplicit(ctree, cpt, isView = isView, silent = silent, withMacrosDisabled = withMacrosDisabled, pos = cpos) @@ -409,7 +410,7 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf => def compile(tree: u.Tree): () => Any = { if (compiler.settings.verbose.value) println("importing "+tree) - var ctree: compiler.Tree = importer.importTree(tree) + val ctree: compiler.Tree = importer.importTree(tree) if (compiler.settings.verbose.value) println("compiling "+ctree) compiler.compile(ctree) diff --git a/src/library/scala/collection/SeqLike.scala b/src/library/scala/collection/SeqLike.scala index a1749a480b..33b6ab4165 100644 --- a/src/library/scala/collection/SeqLike.scala +++ b/src/library/scala/collection/SeqLike.scala @@ -103,7 +103,7 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[ def segmentLength(p: A => Boolean, from: Int): Int = { var i = 0 - var it = iterator.drop(from) + val it = iterator.drop(from) while (it.hasNext && p(it.next())) i += 1 i @@ -111,7 +111,7 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[ def indexWhere(p: A => Boolean, from: Int): Int = { var i = from - var it = iterator.drop(from) + val it = iterator.drop(from) while (it.hasNext) { if (p(it.next())) return i else i += 1 @@ -177,10 +177,10 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[ result } private def swap(i: Int, j: Int) { - var tmpI = idxs(i) + val tmpI = idxs(i) idxs(i) = idxs(j) idxs(j) = tmpI - var tmpE = elms(i) + val tmpE = elms(i) elms(i) = elms(j) elms(j) = tmpE } @@ -777,7 +777,7 @@ object SeqLike { val iter = S.iterator.drop(m0) val Wopt = kmpOptimizeWord(W, n0, n1, true) val T = kmpJumpTable(Wopt, n1-n0) - var cache = new Array[AnyRef](n1-n0) // Ring buffer--need a quick way to do a look-behind + val cache = new Array[AnyRef](n1-n0) // Ring buffer--need a quick way to do a look-behind var largest = 0 var i, m = 0 var answer = -1 diff --git a/src/library/scala/collection/concurrent/TrieMap.scala b/src/library/scala/collection/concurrent/TrieMap.scala index b0736ecace..231f8157e4 100644 --- a/src/library/scala/collection/concurrent/TrieMap.scala +++ b/src/library/scala/collection/concurrent/TrieMap.scala @@ -545,7 +545,7 @@ private[collection] final class CNode[K, V](val bitmap: Int, val array: Array[Ba // removed (those existing when the op began) // - if there are only null-i-nodes below, returns null def toCompressed(ct: TrieMap[K, V], lev: Int, gen: Gen) = { - var bmp = bitmap + val bmp = bitmap var i = 0 val arr = array val tmparray = new Array[BasicNode](arr.length) diff --git a/src/library/scala/collection/immutable/HashMap.scala b/src/library/scala/collection/immutable/HashMap.scala index ee41e2aa3c..9b6183c0a4 100644 --- a/src/library/scala/collection/immutable/HashMap.scala +++ b/src/library/scala/collection/immutable/HashMap.scala @@ -471,9 +471,6 @@ time { mNew.iterator.foreach( p => ()) } // condition below is due to 2 things: // 1) no unsigned int compare on JVM // 2) 0 (no lsb) should always be greater in comparison - val a = thislsb - 1 - val b = thatlsb - 1 - if (unsignedCompare(thislsb - 1, thatlsb - 1)) { val m = thiselems(thisi) totalelems += m.size diff --git a/src/library/scala/collection/immutable/TrieIterator.scala b/src/library/scala/collection/immutable/TrieIterator.scala index e8e904f1f9..3f1c5ea57a 100644 --- a/src/library/scala/collection/immutable/TrieIterator.scala +++ b/src/library/scala/collection/immutable/TrieIterator.scala @@ -177,7 +177,6 @@ private[collection] abstract class TrieIterator[+T](elems: Array[Iterable[T]]) e if (depth > 0) { // 2) topmost comes before (is not) arrayD // steal a portion of top to create a new iterator - val topmost = arrayStack(0) if (posStack(0) == arrayStack(0).length - 1) { // 2a) only a single entry left on top // this means we have to modify this iterator - pop topmost diff --git a/src/library/scala/collection/immutable/Vector.scala b/src/library/scala/collection/immutable/Vector.scala index 1f90436636..7e1f3eadd0 100644 --- a/src/library/scala/collection/immutable/Vector.scala +++ b/src/library/scala/collection/immutable/Vector.scala @@ -242,8 +242,8 @@ override def companion: GenericCompanion[Vector] = Vector private[immutable] def appendFront[B>:A](value: B): Vector[B] = { if (endIndex != startIndex) { - var blockIndex = (startIndex - 1) & ~31 - var lo = (startIndex - 1) & 31 + val blockIndex = (startIndex - 1) & ~31 + val lo = (startIndex - 1) & 31 if (startIndex != blockIndex + 32) { val s = new Vector(startIndex - 1, endIndex, blockIndex) @@ -339,8 +339,8 @@ override def companion: GenericCompanion[Vector] = Vector // //println("------- append " + value) // debug() if (endIndex != startIndex) { - var blockIndex = endIndex & ~31 - var lo = endIndex & 31 + val blockIndex = endIndex & ~31 + val lo = endIndex & 31 if (endIndex != blockIndex) { //println("will make writable block (from "+focus+") at: " + blockIndex) @@ -574,9 +574,7 @@ override def companion: GenericCompanion[Vector] = Vector } private def dropFront0(cutIndex: Int): Vector[A] = { - var blockIndex = cutIndex & ~31 - var lo = cutIndex & 31 - + val blockIndex = cutIndex & ~31 val xor = cutIndex ^ (endIndex - 1) val d = requiredDepth(xor) val shift = (cutIndex & ~((1 << (5*d))-1)) @@ -606,9 +604,7 @@ override def companion: GenericCompanion[Vector] = Vector } private def dropBack0(cutIndex: Int): Vector[A] = { - var blockIndex = (cutIndex - 1) & ~31 - var lo = ((cutIndex - 1) & 31) + 1 - + val blockIndex = (cutIndex - 1) & ~31 val xor = startIndex ^ (cutIndex - 1) val d = requiredDepth(xor) val shift = (startIndex & ~((1 << (5*d))-1)) diff --git a/src/library/scala/collection/mutable/FlatHashTable.scala b/src/library/scala/collection/mutable/FlatHashTable.scala index 74f576b0f7..f1301d2011 100644 --- a/src/library/scala/collection/mutable/FlatHashTable.scala +++ b/src/library/scala/collection/mutable/FlatHashTable.scala @@ -266,7 +266,7 @@ trait FlatHashTable[A] extends FlatHashTable.HashUtils[A] { val totalbuckets = totalSizeMapBuckets var bucketidx = 0 var tableidx = 0 - var tbl = table + val tbl = table var tableuntil = sizeMapBucketSize min tbl.length while (bucketidx < totalbuckets) { var currbucketsz = 0 diff --git a/src/library/scala/collection/mutable/ListBuffer.scala b/src/library/scala/collection/mutable/ListBuffer.scala index bced92e663..0a61b537ce 100644 --- a/src/library/scala/collection/mutable/ListBuffer.scala +++ b/src/library/scala/collection/mutable/ListBuffer.scala @@ -269,7 +269,6 @@ final class ListBuffer[A] if (exported) copy() val n1 = n max 0 val count1 = count min (len - n1) - var old = start.head if (n1 == 0) { var c = count1 while (c > 0) { diff --git a/src/library/scala/collection/parallel/Tasks.scala b/src/library/scala/collection/parallel/Tasks.scala index d6b75202da..af32faf0aa 100644 --- a/src/library/scala/collection/parallel/Tasks.scala +++ b/src/library/scala/collection/parallel/Tasks.scala @@ -66,7 +66,6 @@ trait Task[R, +Tp] { private[parallel] def tryMerge(t: Tp @uncheckedVariance) { val that = t.asInstanceOf[Task[R, Tp]] - val local = result // ensure that any effects of modifying `result` are detected if (this.throwable == null && that.throwable == null) merge(t) mergeThrowables(that) } @@ -167,7 +166,6 @@ trait AdaptiveWorkStealingTasks extends Tasks { while (last.next != null) { // val lastresult = Option(last.body.result) - val beforelast = last last = last.next if (last.tryCancel()) { // println("Done with " + beforelast.body + ", next direct is " + last.body) diff --git a/src/library/scala/collection/parallel/mutable/ParArray.scala b/src/library/scala/collection/parallel/mutable/ParArray.scala index 5ac2725f11..7527c9a71a 100644 --- a/src/library/scala/collection/parallel/mutable/ParArray.scala +++ b/src/library/scala/collection/parallel/mutable/ParArray.scala @@ -184,7 +184,7 @@ self => override def aggregate[S](z: =>S)(seqop: (S, T) => S, combop: (S, S) => S): S = foldLeft[S](z)(seqop) override def sum[U >: T](implicit num: Numeric[U]): U = { - var s = sum_quick(num, arr, until, i, num.zero) + val s = sum_quick(num, arr, until, i, num.zero) i = until s } @@ -200,7 +200,7 @@ self => } override def product[U >: T](implicit num: Numeric[U]): U = { - var p = product_quick(num, arr, until, i, num.one) + val p = product_quick(num, arr, until, i, num.one) i = until p } @@ -432,7 +432,7 @@ self => private def filter2combiner_quick[U >: T, This](pred: T => Boolean, cb: Builder[U, This], a: Array[Any], ntil: Int, from: Int) { var j = i while(j < ntil) { - var curr = a(j).asInstanceOf[T] + val curr = a(j).asInstanceOf[T] if (pred(curr)) cb += curr j += 1 } @@ -447,7 +447,7 @@ self => private def filterNot2combiner_quick[U >: T, This](pred: T => Boolean, cb: Builder[U, This], a: Array[Any], ntil: Int, from: Int) { var j = i while(j < ntil) { - var curr = a(j).asInstanceOf[T] + val curr = a(j).asInstanceOf[T] if (!pred(curr)) cb += curr j += 1 } diff --git a/src/library/scala/collection/parallel/mutable/ParHashMap.scala b/src/library/scala/collection/parallel/mutable/ParHashMap.scala index 3b2c66763e..d8f846dd10 100644 --- a/src/library/scala/collection/parallel/mutable/ParHashMap.scala +++ b/src/library/scala/collection/parallel/mutable/ParHashMap.scala @@ -231,7 +231,7 @@ extends scala.collection.parallel.BucketCombiner[(K, V), ParHashMap[K, V], Defau def setSize(sz: Int) = tableSize = sz def insertEntry(/*block: Int, */e: DefaultEntry[K, V]) = { var h = index(elemHashCode(e.key)) - var olde = table(h).asInstanceOf[DefaultEntry[K, V]] + val olde = table(h).asInstanceOf[DefaultEntry[K, V]] // check if key already exists var ce = olde diff --git a/src/library/scala/collection/parallel/mutable/ParHashSet.scala b/src/library/scala/collection/parallel/mutable/ParHashSet.scala index 22f22c8305..cbfb09bfdd 100644 --- a/src/library/scala/collection/parallel/mutable/ParHashSet.scala +++ b/src/library/scala/collection/parallel/mutable/ParHashSet.scala @@ -263,12 +263,12 @@ with scala.collection.mutable.FlatHashTable.HashUtils[T] { (elemsIn + leftoversIn, elemsLeft concat leftoversLeft) } private def insertAll(atPos: Int, beforePos: Int, elems: UnrolledBuffer[Any]): (Int, UnrolledBuffer[Any]) = { - var leftovers = new UnrolledBuffer[Any] + val leftovers = new UnrolledBuffer[Any] var inserted = 0 var unrolled = elems.headPtr var i = 0 - var t = table + val t = table while (unrolled ne null) { val chunkarr = unrolled.array val chunksz = unrolled.size diff --git a/src/library/scala/collection/parallel/mutable/ParHashTable.scala b/src/library/scala/collection/parallel/mutable/ParHashTable.scala index bb9a7b7823..b203ef8e5d 100644 --- a/src/library/scala/collection/parallel/mutable/ParHashTable.scala +++ b/src/library/scala/collection/parallel/mutable/ParHashTable.scala @@ -110,7 +110,7 @@ trait ParHashTable[K, Entry >: Null <: HashEntry[K, Entry]] extends scala.collec } else Seq(this.asInstanceOf[IterRepr]) private def convertToArrayBuffer(chainhead: Entry): mutable.ArrayBuffer[T] = { - var buff = mutable.ArrayBuffer[Entry]() + val buff = mutable.ArrayBuffer[Entry]() var curr = chainhead while (curr ne null) { buff += curr diff --git a/src/library/scala/collection/parallel/mutable/ResizableParArrayCombiner.scala b/src/library/scala/collection/parallel/mutable/ResizableParArrayCombiner.scala index 68f37137f8..f78de073d6 100644 --- a/src/library/scala/collection/parallel/mutable/ResizableParArrayCombiner.scala +++ b/src/library/scala/collection/parallel/mutable/ResizableParArrayCombiner.scala @@ -26,7 +26,7 @@ trait ResizableParArrayCombiner[T] extends LazyCombiner[T, ParArray[T], ExposedA override def sizeHint(sz: Int) = if (chain.length == 1) chain(0).sizeHint(sz) // public method with private[mutable] type ExposedArrayBuffer in parameter type; cannot be overridden. - def newLazyCombiner(c: ArrayBuffer[ExposedArrayBuffer[T]]) = ResizableParArrayCombiner(c) + final def newLazyCombiner(c: ArrayBuffer[ExposedArrayBuffer[T]]) = ResizableParArrayCombiner(c) def allocateAndCopy = if (chain.size > 1) { val arrayseq = new ArraySeq[T](size) diff --git a/src/library/scala/collection/script/Message.scala b/src/library/scala/collection/script/Message.scala index 7466f2ac3e..43cb8a6138 100644 --- a/src/library/scala/collection/script/Message.scala +++ b/src/library/scala/collection/script/Message.scala @@ -69,7 +69,7 @@ class Script[A] extends ArrayBuffer[Message[A]] with Message[A] { override def toString(): String = { var res = "Script(" - var it = this.iterator + val it = this.iterator var i = 1 while (it.hasNext) { if (i > 1) diff --git a/src/library/scala/util/automata/WordBerrySethi.scala b/src/library/scala/util/automata/WordBerrySethi.scala index b648d179c6..07d5d2ff08 100644 --- a/src/library/scala/util/automata/WordBerrySethi.scala +++ b/src/library/scala/util/automata/WordBerrySethi.scala @@ -140,7 +140,6 @@ abstract class WordBerrySethi extends BaseBerrySethi { val delta1 = immutable.Map(deltaq.zipWithIndex map (_.swap): _*) val finalsArr = (0 until pos map (k => finals.getOrElse(k, 0))).toArray // 0 == not final - val initialsArr = initials.toArray val deltaArr: Array[mutable.Map[_labelT, immutable.BitSet]] = (0 until pos map { x => diff --git a/src/library/scala/util/parsing/input/OffsetPosition.scala b/src/library/scala/util/parsing/input/OffsetPosition.scala index 3366584ab2..115741b9e9 100644 --- a/src/library/scala/util/parsing/input/OffsetPosition.scala +++ b/src/library/scala/util/parsing/input/OffsetPosition.scala @@ -22,7 +22,7 @@ case class OffsetPosition(source: java.lang.CharSequence, offset: Int) extends P /** An index that contains all line starts, including first line, and eof. */ private lazy val index: Array[Int] = { - var lineStarts = new ArrayBuffer[Int] + val lineStarts = new ArrayBuffer[Int] lineStarts += 0 for (i <- 0 until source.length) if (source.charAt(i) == '\n') lineStarts += (i + 1) diff --git a/src/library/scala/xml/PrettyPrinter.scala b/src/library/scala/xml/PrettyPrinter.scala index da82aca33a..8c0a101c2a 100755 --- a/src/library/scala/xml/PrettyPrinter.scala +++ b/src/library/scala/xml/PrettyPrinter.scala @@ -47,7 +47,6 @@ class PrettyPrinter(width: Int, step: Int) { val tmp = width - cur if (s.length <= tmp) return List(Box(ind, s)) - val sb = new StringBuilder() var i = s indexOf ' ' if (i > tmp || i == -1) throw new BrokenException() // cannot break diff --git a/src/library/scala/xml/dtd/ElementValidator.scala b/src/library/scala/xml/dtd/ElementValidator.scala index f97da1c8a3..5260d87b04 100644 --- a/src/library/scala/xml/dtd/ElementValidator.scala +++ b/src/library/scala/xml/dtd/ElementValidator.scala @@ -61,7 +61,7 @@ class ElementValidator() extends Function1[Node,Boolean] { */ def check(md: MetaData): Boolean = { val len: Int = exc.length - var ok = new mutable.BitSet(adecls.length) + val ok = new mutable.BitSet(adecls.length) for (attr <- md) { def attrStr = attr.value.toString diff --git a/src/library/scala/xml/include/sax/XIncludeFilter.scala b/src/library/scala/xml/include/sax/XIncludeFilter.scala index 52ddf6b476..ac5a8c8331 100644 --- a/src/library/scala/xml/include/sax/XIncludeFilter.scala +++ b/src/library/scala/xml/include/sax/XIncludeFilter.scala @@ -275,7 +275,7 @@ class XIncludeFilter extends XMLFilterImpl { try { val uc = source.openConnection() val in = new BufferedInputStream(uc.getInputStream()) - var encodingFromHeader = uc.getContentEncoding() + val encodingFromHeader = uc.getContentEncoding() var contentType = uc.getContentType() if (encodingFromHeader != null) encoding = encodingFromHeader diff --git a/src/library/scala/xml/parsing/MarkupParser.scala b/src/library/scala/xml/parsing/MarkupParser.scala index d4dc6da14d..8f8c25805c 100755 --- a/src/library/scala/xml/parsing/MarkupParser.scala +++ b/src/library/scala/xml/parsing/MarkupParser.scala @@ -154,7 +154,7 @@ trait MarkupParser extends MarkupParserCommon with TokenTests var info_enc: Option[String] = None var info_stdl: Option[Boolean] = None - var m = xmlProcInstr() + val m = xmlProcInstr() var n = 0 if (isProlog) @@ -303,10 +303,8 @@ trait MarkupParser extends MarkupParserCommon with TokenTests var scope: NamespaceBinding = pscope var aMap: MetaData = Null while (isNameStart(ch)) { - val pos = this.pos - val qname = xName - val _ = xEQ + xEQ // side effect val value = xAttributeValue() Utility.prefix(qname) match { @@ -423,7 +421,7 @@ trait MarkupParser extends MarkupParserCommon with TokenTests * content1 ::= '<' content1 | '&' charref ... * }}} */ def content(pscope: NamespaceBinding): NodeSeq = { - var ts = new NodeBuffer + val ts = new NodeBuffer var exit = eof // todo: optimize seq repr. def done = new NodeSeq { val theSeq = ts.toList } @@ -582,7 +580,6 @@ trait MarkupParser extends MarkupParserCommon with TokenTests var exit = false while (! exit) { putChar(ch) - val opos = pos nextch exit = eof || ( ch == '<' ) || ( ch == '&' ) @@ -828,7 +825,6 @@ trait MarkupParser extends MarkupParserCommon with TokenTests * }}} */ def entityDecl() = { var isParameterEntity = false - var entdef: EntityDef = null xToken("NTITY") xSpace if ('%' == ch) { diff --git a/src/msil/ch/epfl/lamp/compiler/msil/emit/ILPrinterVisitor.scala b/src/msil/ch/epfl/lamp/compiler/msil/emit/ILPrinterVisitor.scala index 0ed5e3f3bb..413b08ddd8 100644 --- a/src/msil/ch/epfl/lamp/compiler/msil/emit/ILPrinterVisitor.scala +++ b/src/msil/ch/epfl/lamp/compiler/msil/emit/ILPrinterVisitor.scala @@ -96,7 +96,7 @@ abstract class ILPrinterVisitor extends Visitor { protected def println(s: String){ print(s); println() } protected def println(o: Object){ print(o); println() } protected def printName(name: String) { - var ch = name.charAt(0) + val ch = name.charAt(0) //if (Character.isLetter(ch) && Character.isLowerCase(ch)) { if ((ch != '.') && (ch != '!')) { print('\''); print(name); print('\'') @@ -174,7 +174,6 @@ abstract class ILPrinterVisitor extends Visitor { print(constraintFlags(tVar)) if(tVar.Constraints.length > 0) { print('(') - val lastCnstrtIdx = tVar.Constraints.length - 1 for (ic <- 0 until tVar.Constraints.length) { val cnstrt = tVar.Constraints(ic) printReference(cnstrt) @@ -211,7 +210,7 @@ abstract class ILPrinterVisitor extends Visitor { print(" extends ") printReference(`type`.BaseType()) } - var ifaces: Array[Type] = `type`.getInterfaces() + val ifaces: Array[Type] = `type`.getInterfaces() if (ifaces.length > 0) { println() print(" implements ") @@ -331,7 +330,7 @@ abstract class ILPrinterVisitor extends Visitor { def msilSyntaxDouble(valDou: java.lang.Double) : String = { // !!! check if encoding is correct - var bits = java.lang.Double.doubleToRawLongBits(valDou.doubleValue()) + val bits = java.lang.Double.doubleToRawLongBits(valDou.doubleValue()) /* see p. 170 in Lidin's book Expert .NET 2.0 IL Assembler */ /* Note: no value is equal to Nan, including NaN. Thus, x == Double.NaN always evaluates to false. */ val res = if (valDou.isNaN) "0xffffffffffffffff /* NaN */ " /* TODO this is 'quiet NaN, http://www.savrola.com/resources/NaN.html , what's the difference with a 'signaling NaN'?? */ @@ -452,7 +451,7 @@ abstract class ILPrinterVisitor extends Visitor { */ @throws(classOf[IOException]) def caseOpCode(opCode: OpCode) { - var opString = opCode.toString() + val opString = opCode.toString() print(opString) pad(14 - opString.length()) @@ -661,7 +660,7 @@ abstract class ILPrinterVisitor extends Visitor { print(' '); printReference(method.DeclaringType) print("::"); printName(method.Name) - var params = method.GetParameters() + val params = method.GetParameters() print("(") for (i <- 0 until params.length) { if (i > 0) print(", ") @@ -744,7 +743,7 @@ abstract class ILPrinterVisitor extends Visitor { } def printAttributes(icap: ICustomAttributeProvider) { - var attrs = icap.GetCustomAttributes(false) + val attrs = icap.GetCustomAttributes(false) for (i <- 0 until attrs.length) { print(".custom ") printSignature((attrs(i).asInstanceOf[Attribute]).getConstructor()) @@ -767,7 +766,7 @@ object ILPrinterVisitor { def hasControlChars(str: String): Boolean = { for(i <- 0 until str.length()) { - var ch = str.charAt(i) + val ch = str.charAt(i) ch match { case '\b' => case '\t' => @@ -789,7 +788,7 @@ object ILPrinterVisitor { case e : java.io.UnsupportedEncodingException => throw new RuntimeException(e) } } - var str = new StringBuffer(s) + val str = new StringBuffer(s) var ss = EMPTY var i = 0 while(i < str.length()) { @@ -834,7 +833,7 @@ object ILPrinterVisitor { final var primitive = scala.collection.mutable.Map.empty[Type, String] def addPrimitive(name: String, sig: String) { - var `type` = + val `type` = Type.GetType(name) assert(`type` != null, "Cannot lookup primitive type " + `type`) primitive.put(`type`, sig) diff --git a/src/msil/ch/epfl/lamp/compiler/msil/emit/ModuleBuilder.scala b/src/msil/ch/epfl/lamp/compiler/msil/emit/ModuleBuilder.scala index 981e855e0e..2319d5ca27 100644 --- a/src/msil/ch/epfl/lamp/compiler/msil/emit/ModuleBuilder.scala +++ b/src/msil/ch/epfl/lamp/compiler/msil/emit/ModuleBuilder.scala @@ -73,7 +73,7 @@ class ModuleBuilder(name: String, fullname: String, scopeName: String, assembly: baseType: Type, interfaces: Array[Type]): TypeBuilder = { - var t: Type = GetType(typeName) // Module.GetType(String) + val t: Type = GetType(typeName) // Module.GetType(String) if (t != null) throw new RuntimeException ("Type [" + Assembly + "]" + typeName + "' already exists!") diff --git a/src/msil/ch/epfl/lamp/compiler/msil/emit/MultipleFilesILPrinterVisitor.scala b/src/msil/ch/epfl/lamp/compiler/msil/emit/MultipleFilesILPrinterVisitor.scala index 55c52109b6..bbbbf40508 100644 --- a/src/msil/ch/epfl/lamp/compiler/msil/emit/MultipleFilesILPrinterVisitor.scala +++ b/src/msil/ch/epfl/lamp/compiler/msil/emit/MultipleFilesILPrinterVisitor.scala @@ -41,7 +41,7 @@ final class MultipleFilesILPrinterVisitor(destPath: String, sourceFilesPath: Str scala.util.Sorting.quickSort(as)(assemblyNameComparator) // Arrays.sort(as, assemblyNameComparator) // print each module - var m: Array[Module] = assemblyBuilder.GetModules() + val m: Array[Module] = assemblyBuilder.GetModules() nomembers = true for(i <- 0 until m.length) { print(m(i).asInstanceOf[ModuleBuilder]) @@ -68,10 +68,10 @@ final class MultipleFilesILPrinterVisitor(destPath: String, sourceFilesPath: Str if (!module.globalsCreated) module.CreateGlobalFunctions() - var m: Array[MethodInfo] = module.GetMethods() + val m: Array[MethodInfo] = module.GetMethods() // "Types" contain all the classes - var t: Array[Type] = module.GetTypes() + val t: Array[Type] = module.GetTypes() for(i <- 0 until t.length) { val tBuilder = t(i).asInstanceOf[TypeBuilder] val sourceFilename = tBuilder.sourceFilename @@ -108,7 +108,7 @@ final class MultipleFilesILPrinterVisitor(destPath: String, sourceFilesPath: Str // now write the global methods (typically contains the "main" method) if(!nomembers) { - var globalMethods: File = new File(destPath, ILPrinterVisitor.currAssembly.GetName().Name + ".msil") + val globalMethods: File = new File(destPath, ILPrinterVisitor.currAssembly.GetName().Name + ".msil") val append = assemblyBuilder.generatedFiles.contains(globalMethods.getPath) out = new PrintWriter(new BufferedWriter(new FileWriter(globalMethods, append))) diff --git a/src/msil/ch/epfl/lamp/compiler/msil/emit/SingleFileILPrinterVisitor.scala b/src/msil/ch/epfl/lamp/compiler/msil/emit/SingleFileILPrinterVisitor.scala index 5d59d4d25a..50e9f45373 100644 --- a/src/msil/ch/epfl/lamp/compiler/msil/emit/SingleFileILPrinterVisitor.scala +++ b/src/msil/ch/epfl/lamp/compiler/msil/emit/SingleFileILPrinterVisitor.scala @@ -48,7 +48,7 @@ final class SingleFileILPrinterVisitor(_fileName: String) extends ILPrinterVisit printAssemblyBoilerplate() // print each module - var m: Array[Module] = assemblyBuilder.GetModules() + val m: Array[Module] = assemblyBuilder.GetModules() nomembers = true for(i <- 0 until m.length) { print(m(i).asInstanceOf[ModuleBuilder]) @@ -78,12 +78,12 @@ final class SingleFileILPrinterVisitor(_fileName: String) extends ILPrinterVisit if (!module.globalsCreated) module.CreateGlobalFunctions() - var m: Array[MethodInfo] = module.GetMethods() + val m: Array[MethodInfo] = module.GetMethods() for(i <- 0 until m.length) { print(m(i).asInstanceOf[MethodBuilder]) } - var t: Array[Type] = module.GetTypes() + val t: Array[Type] = module.GetTypes() for(i <- 0 until t.length) { print(t(i).asInstanceOf[TypeBuilder]) } diff --git a/src/msil/ch/epfl/lamp/compiler/msil/emit/TypeBuilder.scala b/src/msil/ch/epfl/lamp/compiler/msil/emit/TypeBuilder.scala index 57dc883898..0b0b16da65 100644 --- a/src/msil/ch/epfl/lamp/compiler/msil/emit/TypeBuilder.scala +++ b/src/msil/ch/epfl/lamp/compiler/msil/emit/TypeBuilder.scala @@ -221,7 +221,7 @@ class TypeBuilder (module: Module, attributes: Int, fullName: String, baseType: object TypeBuilder { def types2String(types: Array[Type]): String = { - var s = new StringBuffer("(") + val s = new StringBuffer("(") for(i <- 0 until types.length) { if (i > 0) s.append(", ") s.append(types(i)) diff --git a/src/partest/scala/tools/partest/ScaladocModelTest.scala b/src/partest/scala/tools/partest/ScaladocModelTest.scala index b8a41aabe4..f399b86029 100644 --- a/src/partest/scala/tools/partest/ScaladocModelTest.scala +++ b/src/partest/scala/tools/partest/ScaladocModelTest.scala @@ -86,10 +86,7 @@ abstract class ScaladocModelTest extends DirectTest { private[this] def newDocFactory: DocFactory = { settings = new Settings(_ => ()) settings.scaladocQuietRun = true // yaay, no more "model contains X documentable templates"! - val args = extraSettings + " " + scaladocSettings - val command = new ScalaDoc.Command((CommandLineParser tokenize (args)), settings) - val docFact = new DocFactory(new ConsoleReporter(settings), settings) - docFact + new DocFactory(new ConsoleReporter(settings), settings) } // compile with scaladoc and output the result diff --git a/src/partest/scala/tools/partest/nest/CompileManager.scala b/src/partest/scala/tools/partest/nest/CompileManager.scala index 0f2806214f..1b6fd410cb 100644 --- a/src/partest/scala/tools/partest/nest/CompileManager.scala +++ b/src/partest/scala/tools/partest/nest/CompileManager.scala @@ -71,7 +71,6 @@ class DirectCompiler(val fileManager: FileManager) extends SimpleCompiler { } private def updatePluginPath(options: String): String = { - val dir = fileManager.testRootDir def absolutize(path: String) = Path(path) match { case x if x.isAbsolute => x.path case x => (fileManager.testRootDir / x).toAbsolute.path diff --git a/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala b/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala index 32f14872ec..a517763e04 100644 --- a/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala +++ b/src/partest/scala/tools/partest/nest/ConsoleFileManager.scala @@ -148,11 +148,6 @@ class ConsoleFileManager extends FileManager { latestPartestFile = prefixFile("build/pack/lib/scala-partest.jar") } - val dists = testParent / "dists" - val build = testParent / "build" - // in case of an installed dist, testRootDir is one level deeper - val bin = testParent.parent / "bin" - def mostRecentOf(base: String, names: String*) = names map (x => prefixFile(base + "/" + x).lastModified) reduceLeft (_ max _) diff --git a/src/partest/scala/tools/partest/nest/ConsoleRunner.scala b/src/partest/scala/tools/partest/nest/ConsoleRunner.scala index dddc10b251..a3ce45c86b 100644 --- a/src/partest/scala/tools/partest/nest/ConsoleRunner.scala +++ b/src/partest/scala/tools/partest/nest/ConsoleRunner.scala @@ -26,8 +26,6 @@ class ConsoleRunner extends DirectRunner { private def antFilter(p: Path) = p.isFile && (p endsWith "build.xml") val testSets = { - val pathFilter: Path => Boolean = x => x.isDirectory || (x hasExtension "scala") - List( TestSet("pos", stdFilter, "Testing compiler (on files whose compilation should succeed)"), TestSet("neg", stdFilter, "Testing compiler (on files whose compilation should fail)"), diff --git a/src/partest/scala/tools/partest/nest/RunnerManager.scala b/src/partest/scala/tools/partest/nest/RunnerManager.scala index cce717cddf..2d06cad7e4 100644 --- a/src/partest/scala/tools/partest/nest/RunnerManager.scala +++ b/src/partest/scala/tools/partest/nest/RunnerManager.scala @@ -855,9 +855,8 @@ class RunnerManager(kind: String, val fileManager: FileManager, params: TestRunP if (fileManager.failed && !runner.logFile.canRead) return TestState.Ok - // sys addShutdownHook cleanup() - val ((success, ctx), elapsed) = timed(runner.run()) - val state = if (success) TestState.Ok else TestState.Fail + val (success, ctx) = runner.run() + val state = if (success) TestState.Ok else TestState.Fail runner.reportResult(ctx.writers) state diff --git a/src/reflect/scala/reflect/api/Printers.scala b/src/reflect/scala/reflect/api/Printers.scala index 1e8161aeef..2a10d89234 100644 --- a/src/reflect/scala/reflect/api/Printers.scala +++ b/src/reflect/scala/reflect/api/Printers.scala @@ -7,7 +7,7 @@ import java.io.{ PrintWriter, StringWriter } * * === Printing Trees === * The method `show` displays the "prettified" representation of reflection artifacts. - * This representation provides one with the desugared Java representation of Scala code. + * This representation provides one with the desugared Java representation of Scala code. * For example: * * {{{ @@ -30,7 +30,7 @@ import java.io.{ PrintWriter, StringWriter } * () * } * }}} - * + * * The method `showRaw` displays internal structure of a given reflection object * as a Scala abstract syntax tree (AST), the representation that the Scala typechecker * operates on. @@ -54,7 +54,7 @@ import java.io.{ PrintWriter, StringWriter } * Literal(Constant(2))))))), * Literal(Constant(()))) * }}} - * + * * The method `showRaw` can also print [[scala.reflect.api.Types]] next to the artifacts * being inspected * {{{ @@ -89,7 +89,7 @@ import java.io.{ PrintWriter, StringWriter } * * === Printing Types === * - * The method `show` + * The method `show` * {{{ * scala> import scala.reflect.runtime.universe._ * import scala.reflect.runtime.universe._ @@ -124,7 +124,7 @@ import java.io.{ PrintWriter, StringWriter } * newTermName("y")#2541#GET)) * }}} * - * For more details about `Printer`s and other aspects of Scala reflection, see the + * For more details about `Printer`s and other aspects of Scala reflection, see the * [[http://docs.scala-lang.org/overviews/reflection/overview.html Reflection Guide]] * */ @@ -160,7 +160,7 @@ trait Printers { self: Universe => protected def render(what: Any, mkPrinter: PrintWriter => TreePrinter, printTypes: BooleanFlag = None, printIds: BooleanFlag = None, printKinds: BooleanFlag = None, printMirrors: BooleanFlag = None): String = { val buffer = new StringWriter() val writer = new PrintWriter(buffer) - var printer = mkPrinter(writer) + val printer = mkPrinter(writer) printTypes.value.map(printTypes => if (printTypes) printer.withTypes else printer.withoutTypes) printIds.value.map(printIds => if (printIds) printer.withIds else printer.withoutIds) printKinds.value.map(printKinds => if (printKinds) printer.withKinds else printer.withoutKinds) diff --git a/src/reflect/scala/reflect/internal/BaseTypeSeqs.scala b/src/reflect/scala/reflect/internal/BaseTypeSeqs.scala index 86ea2c099b..8ea86755c6 100644 --- a/src/reflect/scala/reflect/internal/BaseTypeSeqs.scala +++ b/src/reflect/scala/reflect/internal/BaseTypeSeqs.scala @@ -115,7 +115,7 @@ trait BaseTypeSeqs { def map(f: Type => Type): BaseTypeSeq = { // inlined `elems map f` for performance val len = length - var arr = new Array[Type](len) + val arr = new Array[Type](len) var i = 0 while (i < len) { arr(i) = f(elems(i)) diff --git a/src/reflect/scala/reflect/internal/Definitions.scala b/src/reflect/scala/reflect/internal/Definitions.scala index ac1722f069..77564b717f 100644 --- a/src/reflect/scala/reflect/internal/Definitions.scala +++ b/src/reflect/scala/reflect/internal/Definitions.scala @@ -1068,7 +1068,6 @@ trait Definitions extends api.StandardDefinitions { } } def getMemberClass(owner: Symbol, name: Name): ClassSymbol = { - val y = getMember(owner, name.toTypeName) getMember(owner, name.toTypeName) match { case x: ClassSymbol => x case _ => fatalMissingSymbol(owner, name, "member class") @@ -1235,7 +1234,7 @@ trait Definitions extends api.StandardDefinitions { def init() { if (isInitialized) return // force initialization of every symbol that is synthesized or hijacked by the compiler - val forced = symbolsNotPresentInBytecode + val _ = symbolsNotPresentInBytecode isInitialized = true } //init diff --git a/src/reflect/scala/reflect/internal/Mirrors.scala b/src/reflect/scala/reflect/internal/Mirrors.scala index ff58a31d20..a75185899f 100644 --- a/src/reflect/scala/reflect/internal/Mirrors.scala +++ b/src/reflect/scala/reflect/internal/Mirrors.scala @@ -43,7 +43,7 @@ trait Mirrors extends api.Mirrors { if (point > 0) getModuleOrClass(path.toTermName, point) else RootClass val name = path subName (point + 1, len) - var sym = owner.info member name + val sym = owner.info member name val result = if (path.isTermName) sym.suchThat(_ hasFlag MODULE) else sym if (result != NoSymbol) result else { diff --git a/src/reflect/scala/reflect/internal/Printers.scala b/src/reflect/scala/reflect/internal/Printers.scala index 02ec0b0e06..2bd7d1f856 100644 --- a/src/reflect/scala/reflect/internal/Printers.scala +++ b/src/reflect/scala/reflect/internal/Printers.scala @@ -168,7 +168,7 @@ trait Printers extends api.Printers { self: SymbolTable => ) def printFlags(flags: Long, privateWithin: String) { - var mask: Long = if (settings.debug.value) -1L else PrintableFlags + val mask: Long = if (settings.debug.value) -1L else PrintableFlags val s = flagsToString(flags & mask, privateWithin) if (s != "") print(s + " ") } diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala index 0b065bb441..a5fc861b01 100644 --- a/src/reflect/scala/reflect/internal/Types.scala +++ b/src/reflect/scala/reflect/internal/Types.scala @@ -1725,8 +1725,8 @@ trait Types extends api.Types { self: SymbolTable => } protected def defineBaseClassesOfCompoundType(tpe: CompoundType) { - def define = defineBaseClassesOfCompoundType(tpe, force = false) - if (!breakCycles || isPastTyper) define + def define() = defineBaseClassesOfCompoundType(tpe, force = false) + if (!breakCycles || isPastTyper) define() else tpe match { // non-empty parents helpfully excludes all package classes case tpe @ ClassInfoType(_ :: _, _, clazz) if !clazz.isAnonOrRefinementClass => @@ -1735,11 +1735,11 @@ trait Types extends api.Types { self: SymbolTable => defineBaseClassesOfCompoundType(tpe, force = true) else { baseClassesCycleMonitor push clazz - try define + try define() finally baseClassesCycleMonitor pop clazz } case _ => - define + define() } } private def defineBaseClassesOfCompoundType(tpe: CompoundType, force: Boolean) { @@ -1999,7 +1999,7 @@ trait Types extends api.Types { self: SymbolTable => var change = false for ((from, targets) <- refs(NonExpansive).iterator) for (target <- targets) { - var thatInfo = classInfo(target) + val thatInfo = classInfo(target) if (thatInfo.state != Initialized) change = change | thatInfo.propagate() addRefs(NonExpansive, from, thatInfo.getRefs(NonExpansive, target)) @@ -2007,7 +2007,7 @@ trait Types extends api.Types { self: SymbolTable => } for ((from, targets) <- refs(Expansive).iterator) for (target <- targets) { - var thatInfo = classInfo(target) + val thatInfo = classInfo(target) if (thatInfo.state != Initialized) change = change | thatInfo.propagate() addRefs(Expansive, from, thatInfo.getRefs(NonExpansive, target)) @@ -4071,7 +4071,7 @@ trait Types extends api.Types { self: SymbolTable => variance = -variance val tparams1 = mapOver(tparams) variance = -variance - var result1 = this(result) + val result1 = this(result) if ((tparams1 eq tparams) && (result1 eq result)) tp else PolyType(tparams1, result1.substSym(tparams, tparams1)) case TypeBounds(lo, hi) => @@ -4133,7 +4133,7 @@ trait Types extends api.Types { self: SymbolTable => else copyMethodType(tp, params1, result1.substSym(params, params1)) case PolyType(tparams, result) => val tparams1 = mapOver(tparams) - var result1 = this(result) + val result1 = this(result) if ((tparams1 eq tparams) && (result1 eq result)) tp else PolyType(tparams1, result1.substSym(tparams, tparams1)) case NullaryMethodType(result) => @@ -4163,7 +4163,7 @@ trait Types extends api.Types { self: SymbolTable => copyRefinedType(rtp, parents1, decls1) case ExistentialType(tparams, result) => val tparams1 = mapOver(tparams) - var result1 = this(result) + val result1 = this(result) if ((tparams1 eq tparams) && (result1 eq result)) tp else newExistentialType(tparams1, result1.substSym(tparams, tparams1)) case OverloadedType(pre, alts) => diff --git a/src/reflect/scala/reflect/internal/pickling/UnPickler.scala b/src/reflect/scala/reflect/internal/pickling/UnPickler.scala index ca47ef7e26..2cb2c57e32 100644 --- a/src/reflect/scala/reflect/internal/pickling/UnPickler.scala +++ b/src/reflect/scala/reflect/internal/pickling/UnPickler.scala @@ -339,7 +339,7 @@ abstract class UnPickler /*extends scala.reflect.generic.UnPickler*/ { case TYPEREFtpe => val pre = readTypeRef() val sym = readSymbolRef() - var args = until(end, readTypeRef) + val args = until(end, readTypeRef) TypeRef(pre, sym, args) case TYPEBOUNDStpe => TypeBounds(readTypeRef(), readTypeRef()) @@ -759,7 +759,7 @@ abstract class UnPickler /*extends scala.reflect.generic.UnPickler*/ { val tag = readNat() if (tag != MODIFIERS) errorBadSignature("expected a modifiers tag (" + tag + ")") - val end = readNat() + readIndex + val _ = readNat() + readIndex val pflagsHi = readNat() val pflagsLo = readNat() val pflags = (pflagsHi.toLong << 32) + pflagsLo diff --git a/src/reflect/scala/reflect/internal/util/Statistics.scala b/src/reflect/scala/reflect/internal/util/Statistics.scala index 2c90d2d525..b078b7d4f9 100644 --- a/src/reflect/scala/reflect/internal/util/Statistics.scala +++ b/src/reflect/scala/reflect/internal/util/Statistics.scala @@ -257,7 +257,6 @@ quant) def enabled = _enabled def enabled_=(cond: Boolean) = { if (cond && !_enabled) { - val test = new Timer("", Nil) val start = System.nanoTime() var total = 0L for (i <- 1 to 10000) { diff --git a/src/reflect/scala/reflect/runtime/JavaMirrors.scala b/src/reflect/scala/reflect/runtime/JavaMirrors.scala index f517c30fe6..0cfb3fd623 100644 --- a/src/reflect/scala/reflect/runtime/JavaMirrors.scala +++ b/src/reflect/scala/reflect/runtime/JavaMirrors.scala @@ -379,7 +379,7 @@ private[reflect] trait JavaMirrors extends internal.SymbolTable with api.JavaUni val varargMatch = args.length >= params.length - 1 && isVarArgsList(params) if (!perfectMatch && !varargMatch) { val n_arguments = if (isVarArgsList(params)) s"${params.length - 1} or more" else s"${params.length}" - var s_arguments = if (params.length == 1 && !isVarArgsList(params)) "argument" else "arguments" + val s_arguments = if (params.length == 1 && !isVarArgsList(params)) "argument" else "arguments" throw new ScalaReflectionException(s"${showMethodSig(symbol)} takes $n_arguments $s_arguments") } @@ -1042,7 +1042,7 @@ private[reflect] trait JavaMirrors extends internal.SymbolTable with api.JavaUni private def jclassAsScala(jclazz: jClass[_], owner: Symbol): ClassSymbol = { val name = scalaSimpleName(jclazz) val completer = (clazz: Symbol, module: Symbol) => new FromJavaClassCompleter(clazz, module, jclazz) - val (clazz, module) = createClassModule(owner, name, completer) + val (clazz, _) = createClassModule(owner, name, completer) classCache enter (jclazz, clazz) clazz } diff --git a/src/reflect/scala/reflect/runtime/SymbolLoaders.scala b/src/reflect/scala/reflect/runtime/SymbolLoaders.scala index 2b192ce570..60b22afd18 100644 --- a/src/reflect/scala/reflect/runtime/SymbolLoaders.scala +++ b/src/reflect/scala/reflect/runtime/SymbolLoaders.scala @@ -116,7 +116,7 @@ private[reflect] trait SymbolLoaders { self: SymbolTable => currentMirror.tryJavaClass(path) match { case Some(cls) => val loadingMirror = currentMirror.mirrorDefining(cls) - val (clazz, module) = + val (_, module) = if (loadingMirror eq currentMirror) { createClassModule(pkgClass, name.toTypeName, new TopClassCompleter(_, _)) } else { diff --git a/src/scalap/scala/tools/scalap/Arguments.scala b/src/scalap/scala/tools/scalap/Arguments.scala index 53f722994d..f01f2ff749 100644 --- a/src/scalap/scala/tools/scalap/Arguments.scala +++ b/src/scalap/scala/tools/scalap/Arguments.scala @@ -87,7 +87,7 @@ object Arguments { i += 2 } } else { - var iter = prefixes.iterator + val iter = prefixes.iterator val j = i while ((i == j) && iter.hasNext) { val prefix = iter.next diff --git a/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSigPrinter.scala b/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSigPrinter.scala index f3d449b87f..78044a9caf 100644 --- a/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSigPrinter.scala +++ b/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSigPrinter.scala @@ -70,7 +70,7 @@ class ScalaSigPrinter(stream: PrintStream, printPrivates: Boolean) { } def isCaseClassObject(o: ObjectSymbol): Boolean = { - val TypeRefType(prefix, classSymbol: ClassSymbol, typeArgs) = o.infoType + val TypeRefType(_, classSymbol: ClassSymbol, _) = o.infoType o.isFinal && (classSymbol.children.find(x => x.isCase && x.isInstanceOf[MethodSymbol]) match { case Some(_) => true case None => false @@ -167,7 +167,7 @@ class ScalaSigPrinter(stream: PrintStream, printPrivates: Boolean) { print("object ") val poName = o.symbolInfo.owner.name print(processName(poName)) - val TypeRefType(prefix, classSymbol: ClassSymbol, typeArgs) = o.infoType + val TypeRefType(_, classSymbol: ClassSymbol, _) = o.infoType printType(classSymbol) print(" {\n") printChildren(level, classSymbol) @@ -179,7 +179,7 @@ class ScalaSigPrinter(stream: PrintStream, printPrivates: Boolean) { printModifiers(o) print("object ") print(processName(o.name)) - val TypeRefType(prefix, classSymbol: ClassSymbol, typeArgs) = o.infoType + val TypeRefType(_, classSymbol: ClassSymbol, _) = o.infoType printType(classSymbol) print(" {\n") printChildren(level, classSymbol) @@ -191,7 +191,7 @@ class ScalaSigPrinter(stream: PrintStream, printPrivates: Boolean) { val j = str.indexOf("[") if (j > 0) str = str.substring(0, j) str = StringUtil.trimStart(str, "=> ") - var i = str.lastIndexOf(".") + val i = str.lastIndexOf(".") val res = if (i > 0) str.substring(i + 1) else str if (res.length > 1) StringUtil.decapitalize(res.substring(0, 1)) else res.toLowerCase }) diff --git a/test/files/run/reify_newimpl_11.check b/test/files/run/reify_newimpl_11.check index 2f5cb581e6..c019c6db2d 100644 --- a/test/files/run/reify_newimpl_11.check +++ b/test/files/run/reify_newimpl_11.check @@ -1,2 +1,4 @@ -scala.tools.reflect.ToolBoxError: reflective toolbox has failed: -unresolved free type variables (namely: T defined by C in reify_newimpl_11.scala:6:11). have you forgot to use TypeTag annotations for type parameters external to a reifee? if you have troubles tracking free type variables, consider using -Xlog-free-types +scala.tools.reflect.ToolBoxError: reflective toolbox failed due to unresolved free type variables: + T defined by C in reify_newimpl_11.scala:6:11 +have you forgotten to use TypeTag annotations for type parameters external to a reifee? +if you have troubles tracking free type variables, consider using -Xlog-free-types diff --git a/test/files/run/reify_newimpl_13.check b/test/files/run/reify_newimpl_13.check index d518cd7b84..13e3c9af1e 100644 --- a/test/files/run/reify_newimpl_13.check +++ b/test/files/run/reify_newimpl_13.check @@ -1,2 +1,4 @@ -scala.tools.reflect.ToolBoxError: reflective toolbox has failed: -unresolved free type variables (namely: T defined by C in reify_newimpl_13.scala:7:13). have you forgot to use TypeTag annotations for type parameters external to a reifee? if you have troubles tracking free type variables, consider using -Xlog-free-types +scala.tools.reflect.ToolBoxError: reflective toolbox failed due to unresolved free type variables: + T defined by C in reify_newimpl_13.scala:7:13 +have you forgotten to use TypeTag annotations for type parameters external to a reifee? +if you have troubles tracking free type variables, consider using -Xlog-free-types diff --git a/test/files/run/reify_newimpl_19.check b/test/files/run/reify_newimpl_19.check index 8b8652f92c..c749d4f106 100644 --- a/test/files/run/reify_newimpl_19.check +++ b/test/files/run/reify_newimpl_19.check @@ -1,2 +1,4 @@ -scala.tools.reflect.ToolBoxError: reflective toolbox has failed: -unresolved free type variables (namely: T defined by C in reify_newimpl_19.scala:7:10). have you forgot to use TypeTag annotations for type parameters external to a reifee? if you have troubles tracking free type variables, consider using -Xlog-free-types +scala.tools.reflect.ToolBoxError: reflective toolbox failed due to unresolved free type variables: + T defined by C in reify_newimpl_19.scala:7:10 +have you forgotten to use TypeTag annotations for type parameters external to a reifee? +if you have troubles tracking free type variables, consider using -Xlog-free-types |