diff options
author | michelou <michelou@epfl.ch> | 2008-01-18 19:53:56 +0000 |
---|---|---|
committer | michelou <michelou@epfl.ch> | 2008-01-18 19:53:56 +0000 |
commit | 456729b845c3360f8d7b100b774b7432d2e4ed2f (patch) | |
tree | 0feb56bdf6de587275edcfa9cb16f7283f962f23 /src/compiler/scala/tools/nsc | |
parent | e56b12033dd2a047b06e943cf6bf0e058d3f4679 (diff) | |
download | scala-456729b845c3360f8d7b100b774b7432d2e4ed2f.tar.gz scala-456729b845c3360f8d7b100b774b7432d2e4ed2f.tar.bz2 scala-456729b845c3360f8d7b100b774b7432d2e4ed2f.zip |
removed more warnings
Diffstat (limited to 'src/compiler/scala/tools/nsc')
7 files changed, 51 insertions, 48 deletions
diff --git a/src/compiler/scala/tools/nsc/Interpreter.scala b/src/compiler/scala/tools/nsc/Interpreter.scala index 79b80e28b5..42c54a759b 100644 --- a/src/compiler/scala/tools/nsc/Interpreter.scala +++ b/src/compiler/scala/tools/nsc/Interpreter.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2007 LAMP/EPFL + * Copyright 2005-2008 LAMP/EPFL * @author Martin Odersky */ // $Id$ @@ -781,7 +781,7 @@ class Interpreter(val settings: Settings, out: PrintWriter) { val names1 = getTypes(valAndVarNames, n=>compiler.nme.getterToLocal(n)) val names2 = getTypes(defNames, identity) - names1.incl(names2) + names1 ++ names2 } /** load and run the code using reflection */ @@ -794,13 +794,11 @@ class Interpreter(val settings: Settings, out: PrintWriter) { (resultValMethod.invoke(interpreterResultObject, null).toString(), true) } catch { - case e => { + case e => def caus(e: Throwable): Throwable = if (e.getCause eq null) e else caus(e.getCause) - val orig = caus(e) - (stringFrom(str => orig.printStackTrace(str)), - false) - } + val orig = caus(e) + (stringFrom(str => orig.printStackTrace(str)), false) } } diff --git a/src/compiler/scala/tools/nsc/ast/Trees.scala b/src/compiler/scala/tools/nsc/ast/Trees.scala index 613377518d..61b73a0d45 100644 --- a/src/compiler/scala/tools/nsc/ast/Trees.scala +++ b/src/compiler/scala/tools/nsc/ast/Trees.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2007 LAMP/EPFL + * Copyright 2005-2008 LAMP/EPFL * @author Martin Odersky */ // $Id$ @@ -8,10 +8,10 @@ package scala.tools.nsc.ast import java.io.{PrintWriter, StringWriter} +import scala.collection.mutable.ListBuffer import scala.tools.nsc.symtab.{Flags, SymbolTable} import scala.tools.nsc.symtab.Flags._ import scala.tools.nsc.util.{FreshNameCreator, HashSet, Position, NoPosition, SourceFile} -import scala.collection.mutable.ListBuffer trait Trees { @@ -125,7 +125,7 @@ trait Trees { def isErroneous = (tpe ne null) && tpe.isErroneous /** Apply `f' to each subtree */ - def foreach(f: Tree => Unit): Unit = new ForeachTreeTraverser(f).traverse(this) + def foreach(f: Tree => Unit) { new ForeachTreeTraverser(f).traverse(this) } /** Find all subtrees matching predicate `p' */ def filter(f: Tree => Boolean): List[Tree] = { @@ -160,7 +160,7 @@ trait Trees { case t: Tree => this eq t case _ => false } - def hashCodeStructure : Int = { + def hashCodeStructure: Int = { var hc = getClass.hashCode def f(what : Any) : Unit = what match { case what : Tree => hc += what.hashCodeStructure @@ -169,7 +169,7 @@ trait Trees { case null => case what => hc += what.hashCode } - def g(what : Product) : Unit = { + def g(what: Product) { hc += what.productArity var i = 0 while (i < what.productArity) { @@ -436,7 +436,7 @@ trait Trees { /** Abstract type, type parameter, or type alias */ case class TypeDef(mods: Modifiers, name: Name, tparams: List[TypeDef], rhs: Tree) extends MemberDef { - def namePos = pos.offset.map(n => n - name.length).get(-1) + def namePos = pos.offset.map(n => n - name.length).getOrElse(-1) } /** A TypeDef node which defines given `sym' with given tight hand side `rhs'. */ diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala index 2ac58e4a0d..6c2c5f36ba 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2007 LAMP/EPFL + * Copyright 2005-2008 LAMP/EPFL * @author Martin Odersky */ // $Id$ @@ -961,7 +961,7 @@ trait Scanners { // XML lexing---------------------------------------------------------------- def xSync = { - token = NEWLINE; // avoid getting NEWLINE from nextToken if last was RBRACE + token = NEWLINE // avoid getting NEWLINE from nextToken if last was RBRACE //in.next nextToken } @@ -1030,7 +1030,7 @@ trait Scanners { def error (pos: Int, msg: String) = unit. error(pos, msg) def incompleteInputError(pos: Int, msg: String) = unit.incompleteInputError(pos, msg) def deprecationWarning(pos: Int, msg: String) = unit.deprecationWarning(pos, msg) - implicit def p2g(pos: Position): Int = pos.offset.get(-1) + implicit def p2g(pos: Position): Int = pos.offset.getOrElse(-1) implicit def g2p(pos: Int): Position = new OffsetPosition(unit.source, pos) } } diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala index 72c74804fb..9192f9c043 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2007 LAMP/EPFL + * Copyright 2005-2008 LAMP/EPFL * @author Martin Odersky */ @@ -13,6 +13,8 @@ import scala.collection.immutable.{Set, ListSet} /** * Compute liveness information for local variables. + * + * @author Iulian Dragos */ abstract class Liveness { val global: Global @@ -31,7 +33,7 @@ abstract class Liveness { override def equals(that: Any): Boolean = this eq that.asInstanceOf[AnyRef] } - def lub2(a: Elem, b: Elem): Elem = a incl b + def lub2(a: Elem, b: Elem): Elem = a ++ b } final class LivenessAnalysis extends DataFlowAnalysis[livenessLattice.type] { @@ -43,13 +45,13 @@ abstract class Liveness { val gen: Map[BasicBlock, Set[Local]] = new HashMap() val kill:Map[BasicBlock, Set[Local]] = new HashMap() - def init(m: IMethod): Unit = { + def init(m: IMethod) { this.method = m gen.clear kill.clear - for (val b <- m.code.blocks.toList; - val Pair(g, k) = genAndKill(b)) { + for (b <- m.code.blocks.toList; + (g, k) = genAndKill(b)) { gen += b -> g kill += b -> k } @@ -66,10 +68,10 @@ abstract class Liveness { import opcodes._ /** Return the gen and kill sets for this block. */ - def genAndKill(b: BasicBlock): Pair[Set[Local], Set[Local]] = { + def genAndKill(b: BasicBlock): (Set[Local], Set[Local]) = { var genSet = new ListSet[Local] var killSet = new ListSet[Local] - for (val i <- b.toList) i match { + for (i <- b.toList) i match { case LOAD_LOCAL(local) if (!killSet(local)) => genSet = genSet + local case STORE_LOCAL(local) if (!genSet(local)) => killSet = killSet + local case _ => () @@ -77,7 +79,7 @@ abstract class Liveness { Pair(genSet, killSet) } - override def run: Unit = { + override def run { backwardAnalysis(blockTransfer) if (settings.debug.value) { linearizer.linearize(method).foreach(b => if (b != method.code.startBlock) @@ -87,7 +89,7 @@ abstract class Liveness { } def blockTransfer(b: BasicBlock, out: lattice.Elem): lattice.Elem = - gen(b) incl (out excl kill(b)) + gen(b) ++ (out excl kill(b)) /** Abstract interpretation for one instruction. Very important: * liveness is a backward DFA, so this method should be used to compute diff --git a/src/compiler/scala/tools/nsc/symtab/Symbols.scala b/src/compiler/scala/tools/nsc/symtab/Symbols.scala index ca854b2aaf..35440ec24a 100644 --- a/src/compiler/scala/tools/nsc/symtab/Symbols.scala +++ b/src/compiler/scala/tools/nsc/symtab/Symbols.scala @@ -1,15 +1,16 @@ /* NSC -- new Scala compiler - * Copyright 2005-2007 LAMP/EPFL + * Copyright 2005-2008 LAMP/EPFL * @author Martin Odersky */ // $Id$ package scala.tools.nsc.symtab +import java.util.regex.Pattern + import scala.tools.nsc.io.AbstractFile import scala.tools.nsc.util.{Position, NoPosition, SourceFile, BatchSourceFile} import Flags._ -import java.util.regex.Pattern import nsc.util.RegexCache trait Symbols { @@ -53,7 +54,7 @@ trait Symbols { def setPos(pos: Position): this.type = { this.rawpos = pos; this } def namePos(source: BatchSourceFile) = { - val pos: Int = this.pos.offset.get(-1) + val pos: Int = this.pos.offset.getOrElse(-1) val buf = source.content if (pos == -1) -1 else if (isTypeParameter) pos - name.length diff --git a/src/compiler/scala/tools/nsc/transform/TypingTransformers.scala b/src/compiler/scala/tools/nsc/transform/TypingTransformers.scala index b775d95ecf..bfe0a279c2 100644 --- a/src/compiler/scala/tools/nsc/transform/TypingTransformers.scala +++ b/src/compiler/scala/tools/nsc/transform/TypingTransformers.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2007 LAMP/EPFL + * Copyright 2005-2008 LAMP/EPFL * @author Martin Odersky */ // $Id$ @@ -29,7 +29,7 @@ trait TypingTransformers { def atOwner[A](tree: Tree, owner: Symbol)(trans: => A): A = { val savedLocalTyper = localTyper localTyper = localTyper.atOwner(tree, owner) - typers += owner -> localTyper + typers += Pair(owner, localTyper) val result = super.atOwner(owner)(trans) localTyper = savedLocalTyper typers -= owner diff --git a/src/compiler/scala/tools/nsc/util/Position.scala b/src/compiler/scala/tools/nsc/util/Position.scala index 91c437ee8a..4c58ef00a2 100644 --- a/src/compiler/scala/tools/nsc/util/Position.scala +++ b/src/compiler/scala/tools/nsc/util/Position.scala @@ -1,5 +1,5 @@ /* NSC -- new Scala compiler - * Copyright 2005-2007 LAMP/EPFL + * Copyright 2005-2008 LAMP/EPFL * @author Martin Odersky */ // $Id$ @@ -13,29 +13,31 @@ object Position { trait Position { import Position.tabInc - def offset : Option[Int] = None - def source : Option[SourceFile] = None + def offset: Option[Int] = None + def source: Option[SourceFile] = None def line: Option[Int] = if (offset.isEmpty || source.isEmpty) None else Some(source.get.offsetToLine(offset.get) + 1) - def column: Option[Int] = { - if (offset.isEmpty || source.isEmpty) return None - var column = 1 - // find beginning offset for line - val line = source.get.offsetToLine(offset.get) - var coffset = source.get.lineToOffset(line) - var continue = true - while (continue) { - if (coffset == offset.get(-1)) continue = false - else if (source.get.asInstanceOf[BatchSourceFile].content(coffset) == '\t') - column = ((column - 1) / tabInc * tabInc) + tabInc + 1 - else column += 1 - coffset += 1 + def column: Option[Int] = + if (offset.isEmpty || source.isEmpty) + None + else { + var column = 1 + // find beginning offset for line + val line = source.get.offsetToLine(offset.get) + var coffset = source.get.lineToOffset(line) + var continue = true + while (continue) { + if (coffset == offset.getOrElse(-1)) continue = false + else if (source.get.asInstanceOf[BatchSourceFile].content(coffset) == '\t') + column = ((column - 1) / tabInc * tabInc) + tabInc + 1 + else column += 1 + coffset += 1 + } + Some(column) } - Some(column) - } def lineContent: String = { val line = this.line |