summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/CompilationUnits.scala2
-rw-r--r--src/compiler/scala/tools/nsc/CompileServer.scala1
-rw-r--r--src/compiler/scala/tools/nsc/CompileSocket.scala10
-rw-r--r--src/compiler/scala/tools/nsc/CompilerCommand.scala34
-rw-r--r--src/compiler/scala/tools/nsc/IdeSupport.scala34
-rw-r--r--src/compiler/scala/tools/nsc/Interpreter.scala8
-rw-r--r--src/compiler/scala/tools/nsc/PhaseAssembly.scala149
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Parsers.scala178
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Scanners.scala20
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/AbstractFileClassLoader.scala4
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/JLineReader.scala2
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/SimpleReader.scala4
-rw-r--r--src/compiler/scala/tools/nsc/plugins/Plugin.scala6
-rw-r--r--src/compiler/scala/tools/nsc/plugins/Plugins.scala11
-rw-r--r--src/compiler/scala/tools/nsc/reporters/AbstractReporter.scala4
-rw-r--r--src/compiler/scala/tools/nsc/reporters/Reporter.scala8
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/AbstractFileReader.scala7
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala12
-rw-r--r--src/compiler/scala/tools/nsc/transform/CleanUp.scala3
-rw-r--r--src/compiler/scala/tools/nsc/util/FreshNameCreator.scala60
-rw-r--r--src/library/scala/Application.scala13
-rw-r--r--src/library/scala/Console.scala42
-rw-r--r--src/library/scala/Seq.scala26
-rw-r--r--src/library/scala/SeqProxy.scala10
-rw-r--r--src/library/scala/collection/immutable/Stack.scala11
-rw-r--r--src/library/scala/collection/immutable/TreeHashMap.scala44
-rw-r--r--src/library/scala/deprecated.scala2
-rw-r--r--src/library/scala/io/Position.scala20
-rw-r--r--src/library/scala/io/Source.scala49
-rw-r--r--src/library/scala/io/UTF8Codec.scala20
-rw-r--r--src/library/scala/remote.scala2
-rw-r--r--src/library/scala/util/Sorting.scala4
-rw-r--r--src/partest/scala/tools/partest/PartestTask.scala147
-rw-r--r--src/partest/scala/tools/partest/nest/AntRunner.scala9
-rw-r--r--src/partest/scala/tools/partest/nest/CompileManager.scala23
-rw-r--r--src/partest/scala/tools/partest/nest/ConsoleRunner.scala12
-rw-r--r--src/partest/scala/tools/partest/nest/FileManager.scala5
-rw-r--r--src/partest/scala/tools/partest/nest/NestUI.scala7
-rw-r--r--src/partest/scala/tools/partest/nest/RunnerUtils.scala6
-rw-r--r--src/partest/scala/tools/partest/nest/Worker.scala3
-rw-r--r--src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSigPrinter.scala57
41 files changed, 582 insertions, 487 deletions
diff --git a/src/compiler/scala/tools/nsc/CompilationUnits.scala b/src/compiler/scala/tools/nsc/CompilationUnits.scala
index ea2c466be4..b38ac01c8a 100644
--- a/src/compiler/scala/tools/nsc/CompilationUnits.scala
+++ b/src/compiler/scala/tools/nsc/CompilationUnits.scala
@@ -69,7 +69,7 @@ trait CompilationUnits { self: Global =>
override def toString() = source.toString()
- def clear() = {
+ def clear() {
fresh = null
body = null
depends.clear
diff --git a/src/compiler/scala/tools/nsc/CompileServer.scala b/src/compiler/scala/tools/nsc/CompileServer.scala
index 8b4767018c..dd3133acdb 100644
--- a/src/compiler/scala/tools/nsc/CompileServer.scala
+++ b/src/compiler/scala/tools/nsc/CompileServer.scala
@@ -48,7 +48,6 @@ class StandardCompileServer extends SocketServer {
var reporter: ConsoleReporter = _
-
/** Create a new compiler instance */
def newGlobal(settings: Settings, reporter: Reporter) =
new Global(settings, reporter) {
diff --git a/src/compiler/scala/tools/nsc/CompileSocket.scala b/src/compiler/scala/tools/nsc/CompileSocket.scala
index f5fe702e7a..c22181eabf 100644
--- a/src/compiler/scala/tools/nsc/CompileSocket.scala
+++ b/src/compiler/scala/tools/nsc/CompileSocket.scala
@@ -251,15 +251,15 @@ class CompileSocket {
}
def getPassword(port: Int): String = {
- val ff=portFile(port)
+ val ff = portFile(port)
val f = new BufferedReader(new FileReader(ff))
// allow some time for the server to start up
- var retry=50
- while (ff.length()==0 && retry>0) {
+ var retry = 50
+ while (ff.length() == 0 && retry > 0) {
Thread.sleep(100)
- retry-=1
+ retry -= 1
}
- if (ff.length()==0) {
+ if (ff.length() == 0) {
ff.delete()
fatal("Unable to establish connection to server.")
}
diff --git a/src/compiler/scala/tools/nsc/CompilerCommand.scala b/src/compiler/scala/tools/nsc/CompilerCommand.scala
index c5c7f84434..7896f4e270 100644
--- a/src/compiler/scala/tools/nsc/CompilerCommand.scala
+++ b/src/compiler/scala/tools/nsc/CompilerCommand.scala
@@ -77,33 +77,33 @@ class CompilerCommand(
// start; an informative message of some sort
// should be printed instead.
// (note: do not add "files.isEmpty" do this list)
- val stopSettings=List[(()=>Boolean,
- (Global)=>String)](
- (()=> settings.help.value, compiler =>
- usageMsg + compiler.pluginOptionsHelp
+ val stopSettings = List[(() => Boolean, (Global) => String)](
+ (() => settings.help.value,
+ compiler => usageMsg + compiler.pluginOptionsHelp
),
- (()=> settings.Xhelp.value, compiler =>
- xusageMsg
+ (() => settings.Xhelp.value,
+ compiler => xusageMsg
),
- (()=> settings.Yhelp.value, compiler =>
- yusageMsg
+ (() => settings.Yhelp.value,
+ compiler => yusageMsg
),
- (()=> settings.showPlugins.value, compiler =>
- compiler.pluginDescriptions
+ (() => settings.showPlugins.value,
+ compiler => compiler.pluginDescriptions
),
- (()=> settings.showPhases.value, compiler =>
- compiler.phaseDescriptions
+ (() => settings.showPhases.value,
+ compiler => compiler.phaseDescriptions
)
)
- def shouldStopWithInfo = stopSettings.exists({pair => (pair._1)()})
- def getInfoMessage(compiler:Global) =
- stopSettings.find({pair => (pair._1)()}) match {
- case Some((test,getMessage)) => getMessage(compiler)
+ def shouldStopWithInfo: Boolean =
+ stopSettings.exists(pair => (pair._1)())
+
+ def getInfoMessage(compiler: Global): String =
+ stopSettings.find(pair => (pair._1)()) match {
+ case Some((test, getMessage)) => getMessage(compiler)
case None => ""
}
-
/** Whether the command was processed okay */
var ok = true
diff --git a/src/compiler/scala/tools/nsc/IdeSupport.scala b/src/compiler/scala/tools/nsc/IdeSupport.scala
index 91e7ea47a1..ab1580e124 100644
--- a/src/compiler/scala/tools/nsc/IdeSupport.scala
+++ b/src/compiler/scala/tools/nsc/IdeSupport.scala
@@ -1,12 +1,21 @@
+/* NSC -- new Scala compiler
+ * Copyright 2005-2009 LAMP/EPFL
+ * @author Martin Odersky
+ */
+// $Id$
+
package scala.tools.nsc
+
import scala.tools.nsc.io._
+
trait IdeSupport extends Global with symtab.IdeSupport {
/** to do no dependency tracking */
- protected def normalCompile[T](f : => T) : T = f
- override def unpickleIDEHook : (( => Type) => Type) = f => normalCompile(f)
+ protected def normalCompile[T](f: => T): T = f
+ override def unpickleIDEHook: (( => Type) => Type) = f => normalCompile(f)
+
class IdeRun extends Run {
- override def compiles(sym : Symbol) : Boolean = false // throw new Error
- override def compileLate(file : AbstractFile) = {
+ override def compiles(sym: Symbol): Boolean = false // throw new Error
+ override def compileLate(file: AbstractFile) = {
reloadSource(file)
normalCompile(super.compileLate(file))
}
@@ -14,29 +23,32 @@ trait IdeSupport extends Global with symtab.IdeSupport {
name == "superaccessors" || super.stopPhase(name)
}
-
// load a source file without us caring about adapt.
- def loadSource(file : AbstractFile) : Option[CompilationUnit] = {
+ def loadSource(file: AbstractFile): Option[CompilationUnit] = {
val run = new IdeRun
reloadSource(file)
val source = getSourceFile(file)
try {
normalCompile(run.compileSources(source :: Nil))
- run.units.find(unit => unit.source == source)
+ run.units.find(_.source == source)
} catch {
case e =>
logError("error in presentation normal compile ", e)
None
}
}
+
object loaders1 extends {
- val global : IdeSupport.this.type = IdeSupport.this
+ val global: IdeSupport.this.type = IdeSupport.this
} with scala.tools.nsc.symtab.SymbolLoaders {
import global._
- protected override def completeClassfile(root : global.Symbol, loader : ClassfileLoader)(f : => Unit) : Unit =
+ protected override def completeClassfile(root: global.Symbol, loader: ClassfileLoader)(f: => Unit) {
global.normalCompile(f)
- override def computeDepends(from : PackageLoader) : global.PackageScopeDependMap = IdeSupport.this.computeDepends(from.asInstanceOf[IdeSupport.this.loaders.PackageLoader])
+ }
+ override def computeDepends(from: PackageLoader): global.PackageScopeDependMap =
+ IdeSupport.this.computeDepends(from.asInstanceOf[IdeSupport.this.loaders.PackageLoader])
}
- def computeDepends(from : loaders.PackageLoader) : PackageScopeDependMap = null
+
+ def computeDepends(from: loaders.PackageLoader): PackageScopeDependMap = null
override lazy val loaders = loaders1
}
diff --git a/src/compiler/scala/tools/nsc/Interpreter.scala b/src/compiler/scala/tools/nsc/Interpreter.scala
index a41198a97a..df14417565 100644
--- a/src/compiler/scala/tools/nsc/Interpreter.scala
+++ b/src/compiler/scala/tools/nsc/Interpreter.scala
@@ -94,7 +94,7 @@ class Interpreter(val settings: Settings, out: PrintWriter) {
/** Be quiet. Do not print out the results of each
* submitted command unless an exception is thrown. */
- def beQuiet = { printResults = false }
+ def beQuiet { printResults = false }
/** Temporarily be quiet */
def beQuietDuring[T](operation: => T): T = {
@@ -111,7 +111,9 @@ class Interpreter(val settings: Settings, out: PrintWriter) {
lazy val isettings = new InterpreterSettings
object reporter extends ConsoleReporter(settings, null, out) {
- override def printMessage(msg: String) { out.print(clean(msg) + "\n"); out.flush() }
+ override def printMessage(msg: String) {
+ out.print(clean(msg) + "\n"); out.flush()
+ }
}
/** Instantiate a compiler. Subclasses can override this to
@@ -934,4 +936,4 @@ object Interpreter {
}
res.toString
}
-} \ No newline at end of file
+}
diff --git a/src/compiler/scala/tools/nsc/PhaseAssembly.scala b/src/compiler/scala/tools/nsc/PhaseAssembly.scala
index 1b5306eb0e..f2abe0ca21 100644
--- a/src/compiler/scala/tools/nsc/PhaseAssembly.scala
+++ b/src/compiler/scala/tools/nsc/PhaseAssembly.scala
@@ -1,21 +1,14 @@
-/* __ *\
-** ________ ___ / / ___ Scala Compiler **
-** / __/ __// _ | / / / _ | (c) 2008-2009 , LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-/**
- *
+/* NSC -- new Scala compiler
+ * Copyright 2007-2009 LAMP/EPFL
* @author Anders Bach Nielsen
* @version 1.0
- * $Id$
*/
+// $Id$
package scala.tools.nsc
-import scala.collection.mutable.{HashSet,HashMap}
-import java.io.{BufferedWriter,FileWriter}
+import scala.collection.mutable.{HashSet, HashMap}
+import java.io.{BufferedWriter, FileWriter}
/**
* PhaseAssembly
@@ -40,7 +33,7 @@ trait PhaseAssembly { self: Global =>
* Simple node with name and object ref for the phase object,
* also sets of in and out going dependencies
*/
- class Node(name:String) {
+ class Node(name: String) {
val phasename = name
var phaseobj: Option[List[SubComponent]] = None
val after = new HashSet[Edge]()
@@ -50,7 +43,7 @@ trait PhaseAssembly { self: Global =>
def allPhaseNames(): String = phaseobj match {
case None => phasename
- case Some(lst) => lst.map(sc => sc.phaseName).reduceLeft( (x,y) => x + "," + y)
+ case Some(lst) => lst.map(_.phaseName).reduceLeft(_+","+_)
}
}
@@ -60,8 +53,8 @@ trait PhaseAssembly { self: Global =>
/* Given a phase object, get the node for this phase object. If the
* node object does not exist, then create it.
*/
- def getNodeByPhase(phs : SubComponent) : Node = {
- var node : Node = getNodeByPhase(phs.phaseName)
+ def getNodeByPhase(phs: SubComponent): Node = {
+ var node: Node = getNodeByPhase(phs.phaseName)
node.phaseobj match {
case None =>
node.phaseobj = Some(List[SubComponent](phs))
@@ -73,7 +66,7 @@ trait PhaseAssembly { self: Global =>
/* Given the name of a phase object, get the node for that name. If the
* node object does not exits, then create it.
*/
- def getNodeByPhase(name : String) : Node = {
+ def getNodeByPhase(name: String): Node = {
nodes.get(name).getOrElse {
val node = new Node(name)
nodes += (name -> node)
@@ -108,46 +101,48 @@ trait PhaseAssembly { self: Global =>
/* Given the entire graph, collect the phase objects at each level, where the phase
* names are sorted alphabetical at each level, into the compiler phase list
*/
- def compilerPhaseList() : List[SubComponent] = {
- var chain : List[SubComponent] = Nil
+ def compilerPhaseList(): List[SubComponent] = {
+ var chain: List[SubComponent] = Nil
var lvl = 1
- var nds = nodes.values.filter(n => (n.level == lvl)).toList
+ var nds = nodes.values.filter(_.level == lvl).toList
while(nds.size > 0) {
nds = nds.sort((n1,n2) => (n1.phasename compareTo n2.phasename) < 0)
- for( n <- nds ) {
+ for (n <- nds) {
chain = chain ::: n.phaseobj.get
}
- lvl = lvl + 1
- nds = nodes.values.filter(n => (n.level == lvl)).toList
+ lvl += 1
+ nds = nodes.values.filter(_.level == lvl).toList
}
- return chain
+ chain
}
/* Test if there are cycles in the graph, assign levels to the nodes
* and collapse hard links into nodes
*/
- def collapseHardLinksAndLevels(node : Node, lvl: Int) : Unit = {
+ def collapseHardLinksAndLevels(node: Node, lvl: Int) {
if (node.visited) {
- throw new FatalError("Cycle in compiler phase dependencies detected, phase " + node.phasename + " reacted twice!")
+ throw new FatalError(
+ "Cycle in compiler phase dependencies detected, phase " +
+ node.phasename + " reacted twice!")
}
if (node.level < lvl) node.level = lvl
- var hls = Nil ++ node.before.filter( e => e.hard )
- while( hls.size > 0 ) {
- for( hl <- hls ) {
+ var hls = Nil ++ node.before.filter(_.hard)
+ while (hls.size > 0) {
+ for (hl <- hls) {
node.phaseobj = Some(node.phaseobj.get ++ hl.frm.phaseobj.get)
node.before = hl.frm.before
nodes -= hl.frm.phasename
edges -= hl
- for( edge <- node.before ) edge.to = node
+ for (edge <- node.before) edge.to = node
}
- hls = Nil ++ node.before.filter( e => e.hard )
+ hls = Nil ++ node.before.filter(_.hard)
}
node.visited = true
- for( edge <- node.before ) {
+ for (edge <- node.before) {
collapseHardLinksAndLevels( edge.frm, lvl + 1)
}
@@ -158,20 +153,20 @@ trait PhaseAssembly { self: Global =>
* need to check that its the only dependency. If not, then we will promote the
* other dependencies down
*/
- def validateAndEnforceHardlinks() : Unit = {
- var hardlinks = edges.filter(e => e.hard)
- for(hl <- hardlinks) {
+ def validateAndEnforceHardlinks() {
+ var hardlinks = edges.filter(_.hard)
+ for (hl <- hardlinks) {
if (hl.frm.after.size > 1) {
throw new FatalError("phase " + hl.frm.phasename + " want to run right after " + hl.to.phasename + ", but some phase has declared to run before " + hl.frm.phasename + ". Re-run with -Xgenerate-phase-graph <filename> to better see the problem.")
}
}
var rerun = true
- while(rerun) {
+ while (rerun) {
rerun = false
- hardlinks = edges.filter(e => e.hard)
- for(hl <- hardlinks) {
- var sanity = Nil ++ hl.to.before.filter(e => e.hard)
+ hardlinks = edges.filter(_.hard)
+ for (hl <- hardlinks) {
+ var sanity = Nil ++ hl.to.before.filter(_.hard)
if (sanity.length == 0) {
throw new FatalError("There is no runs right after dependency, where there should be one! This is not supposed to happen!")
} else if (sanity.length > 1) {
@@ -191,7 +186,9 @@ trait PhaseAssembly { self: Global =>
sanity foreach (edge => hl.to.before += edge)
for (edge <- promote) {
rerun = true
- informProgress("promote the dependency of " + edge.frm.phasename + ": " + edge.to.phasename + " => " + hl.frm.phasename)
+ informProgress(
+ "promote the dependency of " + edge.frm.phasename +
+ ": " + edge.to.phasename + " => " + hl.frm.phasename)
edge.to = hl.frm
hl.frm.before += edge
}
@@ -200,20 +197,22 @@ trait PhaseAssembly { self: Global =>
}
}
- /* Remove all nodes in the given graph, that have no phase object
- * Make sure to clean up all edges when removing the node object
- * Inform with warnings, if an external phase has a dependency on something that is dropped.
+ /** Remove all nodes in the given graph, that have no phase object
+ * Make sure to clean up all edges when removing the node object
+ * <code>Inform</code> with warnings, if an external phase has a
+ * dependency on something that is dropped.
*/
- def removeDanglingNodes() : Unit = {
- var dnodes = nodes.values.filter(n => n.phaseobj.isEmpty )
- for(node <- dnodes) {
- informProgress("dropping dependency on node with no phase object: " + node.phasename)
+ def removeDanglingNodes() {
+ var dnodes = nodes.values.filter(_.phaseobj.isEmpty)
+ for (node <- dnodes) {
+ val msg = "dropping dependency on node with no phase object: "+node.phasename
+ informProgress(msg)
nodes -= node.phasename
- for(edge <- node.before) {
+ for (edge <- node.before) {
edges -= edge
edge.frm.after -= edge
edge.frm.phaseobj match {
- case Some(lsc) => if (! lsc.head.internal) warning("dropping dependency on node with no phase object: " + node.phasename)
+ case Some(lsc) => if (! lsc.head.internal) warning(msg)
case _ =>
}
}
@@ -222,71 +221,73 @@ trait PhaseAssembly { self: Global =>
}
-
/* Method called from computePhaseDescriptors in class Global
*/
- def buildCompilerFromPhasesSet() : List[SubComponent] = {
+ def buildCompilerFromPhasesSet(): List[SubComponent] = {
// Add all phases in the set to the graph
val graph = phasesSetToDepGraph(phasesSet)
// Output the phase dependency graph at this stage
- if (!(settings.genPhaseGraph.value == "")) graphToDotFile(graph, settings.genPhaseGraph.value + "1.dot")
+ if (settings.genPhaseGraph.value != "")
+ graphToDotFile(graph, settings.genPhaseGraph.value + "1.dot")
// Remove nodes without phaseobj
graph.removeDanglingNodes()
// Output the phase dependency graph at this stage
- if (!(settings.genPhaseGraph.value == "")) graphToDotFile(graph, settings.genPhaseGraph.value + "2.dot")
+ if (settings.genPhaseGraph.value != "")
+ graphToDotFile(graph, settings.genPhaseGraph.value + "2.dot")
// Validate and Enforce hardlinks / runsRightAfter and promote nodes down the tree
graph.validateAndEnforceHardlinks()
// Output the phase dependency graph at this stage
- if (!(settings.genPhaseGraph.value == "")) graphToDotFile(graph, settings.genPhaseGraph.value + "3.dot")
+ if (settings.genPhaseGraph.value != "")
+ graphToDotFile(graph, settings.genPhaseGraph.value + "3.dot")
// test for cycles, assign levels and collapse hard links into nodes
graph.collapseHardLinksAndLevels(graph.getNodeByPhase("parser"), 1)
// Output the phase dependency graph at this stage
- if (!(settings.genPhaseGraph.value == "")) graphToDotFile(graph, settings.genPhaseGraph.value + "4.dot")
+ if (settings.genPhaseGraph.value != "")
+ graphToDotFile(graph, settings.genPhaseGraph.value + "4.dot")
// assemble the compiler
- return graph.compilerPhaseList()
+ graph.compilerPhaseList()
}
-
- /* Given the phases set, will build a dependency graph from the phases set
- * Using the aux. method of the DependencyGraph to create nodes and egdes
+ /** Given the phases set, will build a dependency graph from the phases set
+ * Using the aux. method of the DependencyGraph to create nodes and egdes.
*/
- private def phasesSetToDepGraph(phsSet : HashSet[SubComponent]) : DependencyGraph = {
+ private def phasesSetToDepGraph(phsSet: HashSet[SubComponent]): DependencyGraph = {
val graph = new DependencyGraph()
- for(phs <- phsSet) {
+ for (phs <- phsSet) {
var fromnode = graph.getNodeByPhase(phs)
phs.runsRightAfter match {
case None =>
- for(phsname <- phs.runsAfter) {
- if (! (phsname == "terminal")) {
- var tonode = graph.getNodeByPhase(phsname)
+ for (phsname <- phs.runsAfter) {
+ if (phsname != "terminal") {
+ val tonode = graph.getNodeByPhase(phsname)
graph.softConnectNodes(fromnode, tonode)
} else {
error("[phase assembly, after dependency on terminal phase not allowed: " + fromnode.phasename + " => "+ phsname + "]")
}
}
- for(phsname <- phs.runsBefore) {
- if (! (phsname == "parser")) {
- var tonode = graph.getNodeByPhase(phsname)
+ for (phsname <- phs.runsBefore) {
+ if (phsname != "parser") {
+ val tonode = graph.getNodeByPhase(phsname)
graph.softConnectNodes(tonode, fromnode)
} else {
error("[phase assembly, before dependency on parser phase not allowed: " + phsname + " => "+ fromnode.phasename + "]")
}
}
case Some(phsname) =>
- if (! (phsname == "terminal")) {
- var tonode = graph.getNodeByPhase(phsname)
+ if (phsname != "terminal") {
+ val tonode = graph.getNodeByPhase(phsname)
graph.hardConnectNodes(fromnode, tonode)
} else {
error("[phase assembly, right after dependency on terminal phase not allowed: " + fromnode.phasename + " => "+ phsname + "]")
@@ -300,12 +301,12 @@ trait PhaseAssembly { self: Global =>
* file showing its structure.
* Plug-in supplied phases are marked as green nodes and hard links are marked as blue edges.
*/
- private def graphToDotFile(graph : DependencyGraph, filename : String) : Unit = {
- var sbuf = new StringBuffer()
+ private def graphToDotFile(graph: DependencyGraph, filename: String) {
+ var sbuf = new StringBuilder
var extnodes = new HashSet[graph.Node]()
var fatnodes = new HashSet[graph.Node]()
sbuf.append("digraph G {\n")
- for(edge <- graph.edges) {
+ for (edge <- graph.edges) {
sbuf.append("\"" + edge.frm.allPhaseNames + "(" + edge.frm.level + ")" + "\"->\"" + edge.to.allPhaseNames + "(" + edge.to.level + ")" + "\"")
if (! edge.frm.phaseobj.get.first.internal) {
extnodes += edge.frm
@@ -318,10 +319,10 @@ trait PhaseAssembly { self: Global =>
sbuf.append(" [color=\"#000000\"]\n")
}
}
- for(node <- extnodes) {
+ for (node <- extnodes) {
sbuf.append("\"" + node.allPhaseNames + "(" + node.level + ")" + "\" [color=\"#00ff00\"]\n")
}
- for(node <- fatnodes) {
+ for (node <- fatnodes) {
sbuf.append("\"" + node.allPhaseNames + "(" + node.level + ")" + "\" [color=\"#0000ff\"]\n")
}
sbuf.append("}\n")
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
index 35627c1c13..ed8a5d1a35 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
@@ -58,19 +58,28 @@ trait Parsers extends NewScanners with MarkupParsers {
import global.posAssigner.atPos
case class OpInfo(operand: Tree, operator: Name, pos: Int)
+
/** ...
*
* @author Sean McDirmid
*/
class UnitParser(val unit: global.CompilationUnit) extends Parser {
val in = new UnitScanner(unit)
- def freshName(pos : Position, prefix : String) = unit.fresh.newName(pos, prefix)
- implicit def i2p(offset : Int) : Position = new OffsetPosition(unit.source,offset)
- def warning(pos : Int, msg : String) : Unit = unit.warning(pos, msg)
- def incompleteInputError(msg: String) : Unit =
+
+ def freshName(pos: Position, prefix: String): Name =
+ unit.fresh.newName(pos, prefix)
+
+ implicit def i2p(offset: Int): Position = new OffsetPosition(unit.source,offset)
+
+ def warning(pos: Int, msg: String) { unit.warning(pos, msg) }
+
+ def incompleteInputError(msg: String) {
unit.incompleteInputError(unit.source.asInstanceOf[BatchSourceFile].content.length - 1, msg)
- def deprecationWarning(pos : Int, msg : String) : Unit = unit.deprecationWarning(pos, msg)
- def syntaxError(pos: Int, msg: String) : Unit = unit.error(pos, msg)
+ }
+ def deprecationWarning(pos: Int, msg: String) {
+ unit.deprecationWarning(pos, msg)
+ }
+ def syntaxError(pos: Int, msg: String) { unit.error(pos, msg) }
/** the markup parser */
def xmlp = {
@@ -108,11 +117,11 @@ trait Parsers extends NewScanners with MarkupParsers {
val in: ParserScanner
//val unit : CompilationUnit
//import in.ScanPosition
- protected def freshName(pos : Position, prefix: String): Name
+ protected def freshName(pos: Position, prefix: String): Name
protected def posToReport: Int = in.currentPos
- protected implicit def i2p(offset : Int) : Position
- //private implicit def p2i(pos : Position) = pos.offset.get
+ protected implicit def i2p(offset: Int): Position
+ //private implicit def p2i(pos: Position) = pos.offset.get
private def inToken = in.token
private def inSkipToken = in.skipToken
@@ -121,10 +130,10 @@ trait Parsers extends NewScanners with MarkupParsers {
private def inNextTokenCode : Int = in.nextTokenCode
private def inName = in.name
private def charVal = in.charVal
- private def intVal(isNegated : Boolean) = in.intVal(isNegated).asInstanceOf[Int]
- private def longVal(isNegated : Boolean) = in.intVal(isNegated)
- private def floatVal(isNegated : Boolean) = in.floatVal(isNegated).asInstanceOf[Float]
- private def doubleVal(isNegated : Boolean) = in.floatVal(isNegated)
+ private def intVal(isNegated: Boolean) = in.intVal(isNegated).asInstanceOf[Int]
+ private def longVal(isNegated: Boolean) = in.intVal(isNegated)
+ private def floatVal(isNegated: Boolean) = in.floatVal(isNegated).asInstanceOf[Float]
+ private def doubleVal(isNegated: Boolean) = in.floatVal(isNegated)
private def stringVal = in.stringVal
/** whether a non-continuable syntax error has been seen */
@@ -133,11 +142,11 @@ trait Parsers extends NewScanners with MarkupParsers {
object treeBuilder extends TreeBuilder {
val global: Parsers.this.global.type = Parsers.this.global
- def freshName(pos : Position, prefix: String): Name = Parser.this.freshName(pos, prefix)
+ def freshName(pos : Position, prefix: String): Name =
+ Parser.this.freshName(pos, prefix)
}
import treeBuilder._
-
/** The implicit view parameters of the surrounding class */
var implicitClassViews: List[Tree] = Nil
@@ -149,7 +158,7 @@ trait Parsers extends NewScanners with MarkupParsers {
t
}
-/* -------- PLACEHOLDERS ------------------------------------------- */
+/* --------------- PLACEHOLDERS ------------------------------------------- */
/** The implicit parameters introduced by `_' in the current expression.
* Parameters appear in reverse order
@@ -199,7 +208,7 @@ trait Parsers extends NewScanners with MarkupParsers {
t
}
-/* -------- ERROR HANDLING ------------------------------------------- */
+/* ------------- ERROR HANDLING ------------------------------------------- */
protected def skip() {
var nparens = 0
@@ -228,14 +237,16 @@ trait Parsers extends NewScanners with MarkupParsers {
inNextToken
}
}
- def warning(pos : Int, msg : String) : Unit
- def incompleteInputError(msg: String) : Unit
- def deprecationWarning(pos : Int, msg : String) : Unit
- private def syntaxError(pos : Position, msg : String, skipIt : Boolean) : Unit = pos.offset match {
- case None => syntaxError(msg,skipIt)
- case Some(offset) => syntaxError(offset, msg, skipIt)
+ def warning(pos: Int, msg: String): Unit
+ def incompleteInputError(msg: String): Unit
+ def deprecationWarning(pos: Int, msg: String): Unit
+ private def syntaxError(pos: Position, msg: String, skipIt: Boolean) {
+ pos.offset match {
+ case None => syntaxError(msg,skipIt)
+ case Some(offset) => syntaxError(offset, msg, skipIt)
+ }
}
- def syntaxError(pos: Int, msg: String) : Unit
+ def syntaxError(pos: Int, msg: String): Unit
def syntaxError(msg: String, skipIt: Boolean) {
syntaxError(inCurrentPos, msg, skipIt)
}
@@ -249,8 +260,8 @@ trait Parsers extends NewScanners with MarkupParsers {
if (skipIt)
skip()
}
- def warning(msg: String) : Unit = warning(inCurrentPos, msg)
+ def warning(msg: String) { warning(inCurrentPos, msg) }
def syntaxErrorOrIncomplete(msg: String, skipIt: Boolean) {
val inToken = this.inToken
@@ -298,7 +309,7 @@ trait Parsers extends NewScanners with MarkupParsers {
if (inToken == token) inNextToken
pos
}
- def surround[T](open : Int, close : Int)(f : => T, orElse : T) : T = {
+ def surround[T](open: Int, close: Int)(f: => T, orElse: T): T = {
val wasOpened = inToken == open
accept(open)
if (wasOpened) {
@@ -308,27 +319,26 @@ trait Parsers extends NewScanners with MarkupParsers {
} else orElse
}
-
/** semi = nl {nl} | `;'
* nl = `\n' // where allowed
*/
- def acceptStatSep() : Boolean = {
+ def acceptStatSep(): Boolean =
if (inToken == NEWLINE || inToken == NEWLINES) { inNextToken; true }
else {
val ret = inToken == SEMI
accept(SEMI)
ret
}
- }
def errorTypeTree = TypeTree().setType(ErrorType).setPos((inCurrentPos))
def errorTermTree = Literal(Constant(null)).setPos((inCurrentPos))
def errorPatternTree = Ident(nme.WILDCARD).setPos((inCurrentPos))
-/* -------- TOKEN CLASSES ------------------------------------------- */
+/* -------------- TOKEN CLASSES ------------------------------------------- */
def isModifier: Boolean = inToken match {
- case ABSTRACT | FINAL | SEALED | PRIVATE | PROTECTED | OVERRIDE | IMPLICIT | LAZY => true
+ case ABSTRACT | FINAL | SEALED | PRIVATE |
+ PROTECTED | OVERRIDE | IMPLICIT | LAZY => true
case _ => false
}
@@ -361,7 +371,8 @@ trait Parsers extends NewScanners with MarkupParsers {
def isExprIntro: Boolean = isExprIntroToken(inToken)
def isTypeIntroToken(token: Int): Boolean = token match {
- case IDENTIFIER | BACKQUOTED_IDENT | THIS | SUPER | USCORE | LPAREN | AT => true
+ case IDENTIFIER | BACKQUOTED_IDENT | THIS |
+ SUPER | USCORE | LPAREN | AT => true
case _ => false
}
@@ -373,7 +384,7 @@ trait Parsers extends NewScanners with MarkupParsers {
def isStatSep: Boolean = isStatSep(inToken)
-/* -------- COMMENT AND ATTRIBUTE COLLECTION ------------------------------------------- */
+/* --------- COMMENT AND ATTRIBUTE COLLECTION ----------------------------- */
/** Join the comment associated with a definition
*/
@@ -383,7 +394,7 @@ trait Parsers extends NewScanners with MarkupParsers {
else trees
}
-/* -------- TREE CONSTRUCTION ------------------------------------------- */
+/* ---------- TREE CONSTRUCTION ------------------------------------------- */
/** Convert tree to formal parameter list
*/
@@ -447,7 +458,7 @@ trait Parsers extends NewScanners with MarkupParsers {
Function(List(makeSyntheticParam(pname)), insertParam(tree))
}
-/* -------- OPERAND/OPERATOR STACK ------------------------------------------- */
+/* --------- OPERAND/OPERATOR STACK --------------------------------------- */
var opstack: List[OpInfo] = Nil
@@ -483,7 +494,8 @@ trait Parsers extends NewScanners with MarkupParsers {
syntaxError(
pos, "left- and right-associative operators with same precedence may not be mixed", false)
- def reduceStack(isExpr: Boolean, base: List[OpInfo], top0: Tree, prec: Int, leftAssoc: Boolean): Tree = {
+ def reduceStack(isExpr: Boolean, base: List[OpInfo], top0: Tree,
+ prec: Int, leftAssoc: Boolean): Tree = {
var top = top0
if (opstack != base && precedence(opstack.head.operator) == prec)
checkAssoc(opstack.head.pos, opstack.head.operator, leftAssoc)
@@ -500,7 +512,6 @@ trait Parsers extends NewScanners with MarkupParsers {
/* -------- IDENTIFIERS AND LITERALS ------------------------------------------- */
-
def ident(): Name =
if (inToken == IDENTIFIER || inToken == BACKQUOTED_IDENT) {
val name = inName.encode
@@ -511,10 +522,9 @@ trait Parsers extends NewScanners with MarkupParsers {
nme.ERROR
}
- def selector(t: Tree) =
+ def selector(t: Tree): Tree =
atPos(inCurrentPos)(Select(t, ident()))
-
/** Path ::= StableId
* | [Ident `.'] this
* AnnotType ::= Path [`.' type]
@@ -576,15 +586,15 @@ trait Parsers extends NewScanners with MarkupParsers {
/** MixinQualifier ::= `[' Id `]'
*/
- def mixinQualifierOpt(pos : Position): (Name,Position) =
+ def mixinQualifierOpt(pos: Position): (Name, Position) =
if (inToken == LBRACKET) {
inNextToken
val pos = inCurrentPos
val name = ident().toTypeName
accept(RBRACKET)
- (name,pos)
+ (name, pos)
} else {
- (nme.EMPTY.toTypeName,pos)
+ (nme.EMPTY.toTypeName, pos)
}
/** StableId ::= Id
@@ -611,15 +621,15 @@ trait Parsers extends NewScanners with MarkupParsers {
def litToTree() = atPos(inCurrentPos) {
Literal(
inToken match {
- case CHARLIT => Constant(charVal)
- case INTLIT => Constant(intVal(isNegated))
- case LONGLIT => Constant(longVal(isNegated))
- case FLOATLIT =>Constant(floatVal(isNegated))
+ case CHARLIT => Constant(charVal)
+ case INTLIT => Constant(intVal(isNegated))
+ case LONGLIT => Constant(longVal(isNegated))
+ case FLOATLIT => Constant(floatVal(isNegated))
case DOUBLELIT => Constant(doubleVal(isNegated))
case STRINGLIT | SYMBOLLIT => Constant(stringVal)
- case TRUE => Constant(true)
- case FALSE => Constant(false)
- case NULL => Constant(null)
+ case TRUE => Constant(true)
+ case FALSE => Constant(false)
+ case NULL => Constant(null)
case _ =>
syntaxErrorOrIncomplete("illegal literal", true)
null
@@ -658,7 +668,7 @@ trait Parsers extends NewScanners with MarkupParsers {
if (inToken == NEWLINE && p(inNextTokenCode)) newLineOpt()
}
-/* -------- TYPES ------------------------------------------- */
+/* ------------- TYPES ---------------------------------------------------- */
/** TypedOpt ::= [`:' Type]
*/
@@ -722,7 +732,9 @@ trait Parsers extends NewScanners with MarkupParsers {
} else {
val ts = types(isPattern, false, true)
accept(RPAREN)
- if (inToken == ARROW) atPos(inSkipToken) { makeFunctionTypeTree(ts, typ(isPattern)) }
+ if (inToken == ARROW) atPos(inSkipToken) {
+ makeFunctionTypeTree(ts, typ(isPattern))
+ }
else {
for (t <- ts) t match {
case AppliedTypeTree(Select(_, n), _)
@@ -745,7 +757,8 @@ trait Parsers extends NewScanners with MarkupParsers {
val whereClauses = refinement()
for (wc <- whereClauses) {
wc match {
- case TypeDef(_, _, _, TypeBoundsTree(_, _)) | ValDef(_, _, _, EmptyTree) | EmptyTree =>
+ case TypeDef(_, _, _, TypeBoundsTree(_, _)) |
+ ValDef(_, _, _, EmptyTree) | EmptyTree =>
;
case _ =>
syntaxError(wc.pos, "not a legal existential clause", false)
@@ -762,7 +775,7 @@ trait Parsers extends NewScanners with MarkupParsers {
infixTypeRest(inCurrentPos, infixTypeFirst(isPattern), isPattern, mode)
}
- def infixTypeFirst(isPattern: Boolean) =
+ def infixTypeFirst(isPattern: Boolean): Tree =
if (inToken == LBRACE) scalaAnyRefConstr else annotType(isPattern)
def infixTypeRest(pos: Int, t0: Tree, isPattern: Boolean, mode: InfixMode.Value): Tree = {
@@ -909,7 +922,7 @@ trait Parsers extends NewScanners with MarkupParsers {
typ()
}
-/* -------- EXPRESSIONS ------------------------------------------- */
+/* ----------- EXPRESSIONS ------------------------------------------------ */
/** EqualsExpr ::= `=' Expr
*/
@@ -1232,10 +1245,13 @@ trait Parsers extends NewScanners with MarkupParsers {
// again, position should be on idetifier, not (
var pos = if (t.pos == NoPosition) i2p(inCurrentPos) else t.pos
simpleExprRest(atPos(pos) {
- // look for anonymous function application like (f _)(x) and translate to (f _).apply(x), bug #460
+ // look for anonymous function application like (f _)(x) and
+ // translate to (f _).apply(x), bug #460
val sel = t match {
- case Parens(List(Typed(_, _: Function))) => Select(stripParens(t), nme.apply)
- case _ => stripParens(t)
+ case Parens(List(Typed(_, _: Function))) =>
+ Select(stripParens(t), nme.apply)
+ case _ =>
+ stripParens(t)
}
Apply(sel, argumentExprs())
}, true)
@@ -1446,7 +1462,7 @@ trait Parsers extends NewScanners with MarkupParsers {
stripParens(reduceStack(false, base, top, 0, true))
}
- def xmlLiteralPattern() : Tree
+ def xmlLiteralPattern(): Tree
/** SimplePattern ::= varid
* | `_'
@@ -1491,14 +1507,16 @@ trait Parsers extends NewScanners with MarkupParsers {
} else t
case USCORE =>
atPos(inSkipToken) { Ident(nme.WILDCARD) }
- case CHARLIT | INTLIT | LONGLIT | FLOATLIT | DOUBLELIT | STRINGLIT | SYMBOLLIT | TRUE | FALSE | NULL =>
+ case CHARLIT | INTLIT | LONGLIT | FLOATLIT | DOUBLELIT |
+ STRINGLIT | SYMBOLLIT | TRUE | FALSE | NULL =>
literal(true, false)
case LPAREN =>
val pos = inSkipToken
val ps = if (inToken == RPAREN) List() else patterns(false)
accept(RPAREN)
Parens(ps) setPos (pos)
- case XMLSTART => xmlLiteralPattern()
+ case XMLSTART =>
+ xmlLiteralPattern()
case _ =>
syntaxErrorOrIncomplete("illegal start of simple pattern", true)
errorPatternTree
@@ -1529,7 +1547,7 @@ trait Parsers extends NewScanners with MarkupParsers {
/** AccessQualifier ::= "[" (Id | this) "]"
*/
- def accessQualifierOpt(mods: Modifiers) = {
+ def accessQualifierOpt(mods: Modifiers): Modifiers = {
var result = mods
if (inToken == LBRACKET) {
inNextToken
@@ -1930,7 +1948,7 @@ trait Parsers extends NewScanners with MarkupParsers {
* | type [nl] TypeDcl
*/
def defOrDcl(mods: Modifiers): List[Tree] = {
- if ((mods.hasFlag(Flags.LAZY)) && in.token != VAL)
+ if ((mods hasFlag Flags.LAZY) && in.token != VAL)
syntaxError("lazy not allowed here. Only vals can be lazy", false)
inToken match {
case VAL =>
@@ -2098,7 +2116,8 @@ trait Parsers extends NewScanners with MarkupParsers {
* | ConstrBlock
*/
def constrExpr(vparamss: List[List[ValDef]]): Tree =
- if (inToken == LBRACE) constrBlock(vparamss) else Block(List(selfInvocation(vparamss)), Literal(()))
+ if (inToken == LBRACE) constrBlock(vparamss)
+ else Block(List(selfInvocation(vparamss)), Literal(()))
/** SelfInvocation ::= this ArgumentExprs {ArgumentExprs}
*/
@@ -2110,8 +2129,8 @@ trait Parsers extends NewScanners with MarkupParsers {
t = Apply(t, argumentExprs())
newLineOptWhenFollowedBy(LBRACE)
}
- if (!implicitClassViews.isEmpty) t = Apply(t, vparamss.last.map(vd => Ident(vd.name)))
- t
+ if (implicitClassViews.isEmpty) t
+ else Apply(t, vparamss.last.map(vp => Ident(vp.name)))
}
/** ConstrBlock ::= `{' SelfInvocation {semi BlockStat} `}'
@@ -2136,9 +2155,9 @@ trait Parsers extends NewScanners with MarkupParsers {
// @M! a type alias as well as an abstract type may declare type parameters
val tparams = inToken match {
case LBRACKET =>
- typeParamClauseOpt(name, null)
+ typeParamClauseOpt(name, null)
case _ =>
- Nil
+ Nil
}
inToken match {
@@ -2206,8 +2225,16 @@ trait Parsers extends NewScanners with MarkupParsers {
if (mods.hasFlag(Flags.TRAIT)) (Modifiers(Flags.TRAIT), List())
else (accessModifierOpt(), paramClauses(name, implicitClassViews, mods.hasFlag(Flags.CASE)))
val thistpe = requiresTypeOpt()
- var mods1 = if (mods.hasFlag( Flags.TRAIT )) if (inToken == SUBTYPE) mods | Flags.DEFERRED else mods
- else if (inToken == SUBTYPE) { syntaxError("classes are not allowed to be virtual", false); mods } else mods
+ var mods1 =
+ if (mods hasFlag Flags.TRAIT)
+ if (inToken == SUBTYPE) mods | Flags.DEFERRED
+ else mods
+ else if (inToken == SUBTYPE) {
+ syntaxError("classes are not allowed to be virtual", false)
+ mods
+ }
+ else
+ mods
var template = templateOpt(mods1, name, constrMods withAnnotations constrAnnots, vparamss)
if (!thistpe.isEmpty) {
if (template.self.isEmpty) {
@@ -2288,14 +2315,15 @@ trait Parsers extends NewScanners with MarkupParsers {
}
}
- def isInterface(mods: Modifiers, body: List[Tree]) =
- (mods.hasFlag(Flags.TRAIT) && (body forall treeInfo.isInterfaceMember))
+ def isInterface(mods: Modifiers, body: List[Tree]): Boolean =
+ (mods hasFlag Flags.TRAIT) && (body forall treeInfo.isInterfaceMember)
/** ClassTemplateOpt ::= 'extends' ClassTemplate | [['extends'] TemplateBody]
* TraitTemplateOpt ::= TraitExtends TraitTemplate | [['extends'] TemplateBody] | '<:' TemplateBody
* TraitExtends ::= 'extends' | `<:'
*/
- def templateOpt(mods: Modifiers, name: Name, constrMods: Modifiers, vparamss: List[List[ValDef]]): Template = {
+ def templateOpt(mods: Modifiers, name: Name, constrMods: Modifiers,
+ vparamss: List[List[ValDef]]): Template = {
val pos = inCurrentPos;
val (parents0, argss, self, body) =
if (inToken == EXTENDS || settings.Xexperimental.value && (mods hasFlag Flags.TRAIT) && inToken == SUBTYPE) {
@@ -2328,7 +2356,7 @@ trait Parsers extends NewScanners with MarkupParsers {
/** TemplateBody ::= [nl] `{' TemplateStatSeq `}'
* @param isPre specifies whether in early initializer (true) or not (false)
*/
- def templateBody(isPre : Boolean) = {
+ def templateBody(isPre: Boolean) = {
accept(LBRACE)
val result @ (self, stats) = templateStatSeq(isPre)
accept(RBRACE)
@@ -2568,7 +2596,9 @@ trait Parsers extends NewScanners with MarkupParsers {
ts ++= topStatSeq()
}
val stats = ts.toList
- val usePos = if (stats.isEmpty || stats.head.pos == NoPosition) i2p(pos) else stats.head.pos
+ val usePos =
+ if (stats.isEmpty || stats.head.pos == NoPosition) i2p(pos)
+ else stats.head.pos
atPos(usePos) { stats match {
case List(stat @ PackageDef(_, _)) => stat
case _ => makePackaging(Ident(nme.EMPTY_PACKAGE_NAME), stats)
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
index 4f24681a88..a2e114afca 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
@@ -71,7 +71,7 @@ trait Scanners {
def floatVal(negated: Boolean): Double
def intVal: Long = intVal(false)
def floatVal: Double = floatVal(false)
- //def token2string(token : Int) : String = configuration.token2string(token)
+ //def token2string(token: Int): String = configuration.token2string(token)
/** return recent scala doc, if any */
def flushDoc: String
}
@@ -152,14 +152,11 @@ trait Scanners {
enterKeyword(nme.ATkw, AT)
// Build keyword array
- key = new Array[Byte](maxKey + 1)
- for (i <- 0 to maxKey)
- key(i) = IDENTIFIER
- for (j <- 0 until tokenCount)
- if (tokenName(j) ne null)
- key(tokenName(j).start) = j.asInstanceOf[Byte]
-
+ key = Array.make(maxKey + 1, IDENTIFIER)
+ for (j <- 0 until tokenCount if tokenName(j) ne null)
+ key(tokenName(j).start) = j.toByte
}
+
//Token representation -----------------------------------------------------
/** Convert name to token */
@@ -1028,9 +1025,12 @@ trait Scanners {
/** ...
*/
class UnitScanner(unit: CompilationUnit) extends Scanner {
- val in = new CharArrayReader(unit.source.asInstanceOf[BatchSourceFile].content, !settings.nouescape.value, syntaxError)
+ val in = new CharArrayReader(
+ unit.source.asInstanceOf[BatchSourceFile].content,
+ !settings.nouescape.value, syntaxError
+ )
def warning(pos: Int, msg: String) = unit.warning(pos, msg)
- def error (pos: Int, msg: String) = unit. error(pos, msg)
+ 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.getOrElse(-1)
diff --git a/src/compiler/scala/tools/nsc/interpreter/AbstractFileClassLoader.scala b/src/compiler/scala/tools/nsc/interpreter/AbstractFileClassLoader.scala
index 40e1ce596f..bb1d049677 100644
--- a/src/compiler/scala/tools/nsc/interpreter/AbstractFileClassLoader.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/AbstractFileClassLoader.scala
@@ -1,8 +1,10 @@
/* NSC -- new Scala compiler
* Copyright 2005-2009 LAMP/EPFL
*/
-// $Id$
+// $Id: $
+
package scala.tools.nsc.interpreter
+
import scala.tools.nsc.io.AbstractFile
/**
diff --git a/src/compiler/scala/tools/nsc/interpreter/JLineReader.scala b/src/compiler/scala/tools/nsc/interpreter/JLineReader.scala
index 8375328017..0e66a8b06a 100644
--- a/src/compiler/scala/tools/nsc/interpreter/JLineReader.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/JLineReader.scala
@@ -4,8 +4,8 @@
*/
// $Id$
-
package scala.tools.nsc.interpreter
+
import java.io.File
import jline.{ History, ConsoleReader, ArgumentCompletor }
diff --git a/src/compiler/scala/tools/nsc/interpreter/SimpleReader.scala b/src/compiler/scala/tools/nsc/interpreter/SimpleReader.scala
index 38dfdbfb92..1bd5f217c1 100644
--- a/src/compiler/scala/tools/nsc/interpreter/SimpleReader.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/SimpleReader.scala
@@ -5,8 +5,8 @@
// $Id$
package scala.tools.nsc.interpreter
-import java.io.{BufferedReader, PrintWriter}
+import java.io.{BufferedReader, PrintWriter}
/** Reads using standard JDK API */
class SimpleReader(
@@ -16,7 +16,7 @@ class SimpleReader(
extends InteractiveReader {
def this() = this(Console.in, new PrintWriter(Console.out), true)
- def readOneLine(prompt: String) = {
+ def readOneLine(prompt: String): String = {
if (interactive) {
out.print(prompt)
out.flush()
diff --git a/src/compiler/scala/tools/nsc/plugins/Plugin.scala b/src/compiler/scala/tools/nsc/plugins/Plugin.scala
index 4ebc83daa2..bce4876c41 100644
--- a/src/compiler/scala/tools/nsc/plugins/Plugin.scala
+++ b/src/compiler/scala/tools/nsc/plugins/Plugin.scala
@@ -81,7 +81,7 @@ object Plugin {
val jar = new JarFile(jarfile)
try {
val ent = jar.getEntry("scalac-plugin.xml")
- if(ent == null) return None
+ if (ent == null) return None
val inBytes = jar.getInputStream(ent)
val packXML = XML.load(inBytes)
@@ -92,7 +92,7 @@ object Plugin {
jar.close()
}
} catch {
- case _:ZipException => None
+ case _: ZipException => None
}
}
@@ -132,7 +132,7 @@ object Plugin {
dir <- dirs if dir.isDirectory
entries = dir.listFiles
if entries ne null
- entry <- entries.toList.sort((f1, f2) => f1.getName <= f2.getName)
+ entry <- entries.toList.sort(_.getName <= _.getName)
if entry.toString.toLowerCase endsWith ".jar"
pdesc <- loadDescription(entry)
if !(ignoring contains pdesc.name)
diff --git a/src/compiler/scala/tools/nsc/plugins/Plugins.scala b/src/compiler/scala/tools/nsc/plugins/Plugins.scala
index cd457dfec1..812bfd7ce8 100644
--- a/src/compiler/scala/tools/nsc/plugins/Plugins.scala
+++ b/src/compiler/scala/tools/nsc/plugins/Plugins.scala
@@ -20,7 +20,8 @@ trait Plugins { self: Global =>
/** Load a rough list of the plugins. For speed, it
* does not instantiate a compiler run. Therefore it cannot
* test for same-named phases or other problems that are
- * filtered from the final list of plugins. */
+ * filtered from the final list of plugins.
+ */
protected def loadRoughPluginsList(): List[Plugin] = {
val jars = settings.plugin.value.map(new File(_))
val dirs =
@@ -41,7 +42,6 @@ trait Plugins { self: Global =>
roughPluginsListCache.get
}
-
/** Load all available plugins. Skips plugins that
* either have the same name as another one, or which
* define a phase name that another one does.
@@ -117,7 +117,6 @@ trait Plugins { self: Global =>
plugs
}
-
private var pluginsCache: Option[List[Plugin]] = None
def plugins: List[Plugin] = {
@@ -126,7 +125,6 @@ trait Plugins { self: Global =>
pluginsCache.get
}
-
/** A description of all the plugins that are loaded */
def pluginDescriptions: String = {
val messages =
@@ -140,10 +138,7 @@ trait Plugins { self: Global =>
* @see phasesSet
*/
protected def computePluginPhases() {
-
- var plugPhases = plugins.flatMap(_.components)
-
- // Add all phases supplied by plugins to the phasesSet
+ val plugPhases = plugins.flatMap(_.components)
for (pPhase <- plugPhases) {
phasesSet += pPhase
}
diff --git a/src/compiler/scala/tools/nsc/reporters/AbstractReporter.scala b/src/compiler/scala/tools/nsc/reporters/AbstractReporter.scala
index 4c62a8435d..d6f94e8626 100644
--- a/src/compiler/scala/tools/nsc/reporters/AbstractReporter.scala
+++ b/src/compiler/scala/tools/nsc/reporters/AbstractReporter.scala
@@ -16,7 +16,7 @@ import scala.tools.nsc.util.Position
abstract class AbstractReporter extends Reporter {
private val positions = new HashMap[Position, Severity]
- override def reset = {
+ override def reset {
super.reset
positions.clear
}
@@ -28,7 +28,7 @@ abstract class AbstractReporter extends Reporter {
protected def info0(pos: Position, msg: String, severity: Severity, force: Boolean) {
severity match {
- case INFO =>
+ case INFO =>
if (force || settings.verbose.value) display(pos, msg, severity)
case WARNING =>
val hidden = testAndLog(pos, severity)
diff --git a/src/compiler/scala/tools/nsc/reporters/Reporter.scala b/src/compiler/scala/tools/nsc/reporters/Reporter.scala
index 3dbdfc85f1..c12e32a026 100644
--- a/src/compiler/scala/tools/nsc/reporters/Reporter.scala
+++ b/src/compiler/scala/tools/nsc/reporters/Reporter.scala
@@ -22,7 +22,7 @@ abstract class Reporter {
val WARNING = new Severity(1)
val ERROR = new Severity(2)
- def reset: Unit = {
+ def reset {
INFO.count = 0
ERROR.count = 0
WARNING.count = 0
@@ -41,9 +41,9 @@ abstract class Reporter {
def setSource(source: SourceFile) { this.source = source }
def getSource: SourceFile = source
- def info(pos: Position, msg: String, force: Boolean): Unit = info0(pos, msg, INFO, force)
- def warning(pos: Position, msg: String ): Unit = info0(pos, msg, WARNING, false)
- def error(pos: Position, msg: String ): Unit = info0(pos, msg, ERROR, false)
+ def info(pos: Position, msg: String, force: Boolean) { info0(pos, msg, INFO, force) }
+ def warning(pos: Position, msg: String ) { info0(pos, msg, WARNING, false) }
+ def error(pos: Position, msg: String ) { info0(pos, msg, ERROR, false) }
/** An error that could possibly be fixed if the unit were longer.
* This is used only when the interpreter tries
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/AbstractFileReader.scala b/src/compiler/scala/tools/nsc/symtab/classfile/AbstractFileReader.scala
index 08f7493b75..3563c69646 100644
--- a/src/compiler/scala/tools/nsc/symtab/classfile/AbstractFileReader.scala
+++ b/src/compiler/scala/tools/nsc/symtab/classfile/AbstractFileReader.scala
@@ -38,22 +38,21 @@ class AbstractFileReader(val file: AbstractFile) {
@throws(classOf[IndexOutOfBoundsException])
def nextByte: Byte = {
val b = buf(bp)
- bp = bp + 1
+ bp += 1
b
}
/** read some bytes
*/
def nextBytes(len: Int): Array[Byte] = {
- bp = bp + len
+ bp += len
buf.subArray(bp - len, bp)
}
/** read a character
*/
- def nextChar: Char = {
+ def nextChar: Char =
(((nextByte & 0xff) << 8) + (nextByte & 0xff)).toChar
- }
/** read an integer
*/
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala
index b40547d9d9..24ba34c572 100644
--- a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala
+++ b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala
@@ -66,11 +66,9 @@ abstract class ICodeReader extends ClassfileParser {
/** If we're parsing a scala module, the owner of members is always
* the module symbol.
*/
- override def getOwner(jflags: Int): Symbol = {
- if (isScalaModule) {
- this.staticModule
- } else super.getOwner(jflags)
- }
+ override def getOwner(jflags: Int): Symbol =
+ if (isScalaModule) this.staticModule
+ else super.getOwner(jflags)
override def parseClass() {
this.instanceCode = new IClass(clazz)
@@ -634,6 +632,7 @@ abstract class ICodeReader extends ClassfileParser {
def isBox(m: Symbol): Boolean =
(m.owner == definitions.BoxesRunTimeClass.moduleClass
&& m.name.startsWith("boxTo"))
+
def isUnbox(m: Symbol): Boolean =
(m.owner == definitions.BoxesRunTimeClass.moduleClass
&& m.name.startsWith("unboxTo"))
@@ -643,7 +642,8 @@ abstract class ICodeReader extends ClassfileParser {
*/
def getCode(flags: Int): IClass =
if (isScalaModule) staticCode
- else if ((flags & JAVA_ACC_STATIC) != 0) staticCode else instanceCode
+ else if ((flags & JAVA_ACC_STATIC) != 0) staticCode
+ else instanceCode
class LinearCode {
var instrs: ListBuffer[(Int, Instruction)] = new ListBuffer
diff --git a/src/compiler/scala/tools/nsc/transform/CleanUp.scala b/src/compiler/scala/tools/nsc/transform/CleanUp.scala
index cf2b194489..52fbc7b83c 100644
--- a/src/compiler/scala/tools/nsc/transform/CleanUp.scala
+++ b/src/compiler/scala/tools/nsc/transform/CleanUp.scala
@@ -621,7 +621,8 @@ abstract class CleanUp extends Transform {
case MethodType(paramTypes, resType) =>
assert(params.length == paramTypes.length)
atPos(ad.pos)(localTyper.typed {
- val sym = currentOwner.newValue(ad.pos, newTermName(unit.fresh.newName("qual"))) setInfo qual0.tpe
+ val t1 = newTermName(unit.fresh.newName(ad.pos, "qual"))
+ val sym = currentOwner.newValue(ad.pos, t1) setInfo qual0.tpe
qual = gen.mkAttributedRef(sym)
Block(
List(ValDef(sym, qual0)),
diff --git a/src/compiler/scala/tools/nsc/util/FreshNameCreator.scala b/src/compiler/scala/tools/nsc/util/FreshNameCreator.scala
index e0070e5827..a25d73a08a 100644
--- a/src/compiler/scala/tools/nsc/util/FreshNameCreator.scala
+++ b/src/compiler/scala/tools/nsc/util/FreshNameCreator.scala
@@ -9,36 +9,46 @@ package scala.tools.nsc.util
import scala.collection.mutable.HashMap
trait FreshNameCreator {
- /** do not call before after type checking ends. Use newName(Position,String) instead. */
- @deprecated def newName(prefix : String) : String
- /** do not call before after type checking ends. Use newName(Position) instead. */
- @deprecated def newName() : String
- def newName(pos : util.Position, prefix : String) : String
- def newName(pos : util.Position) : String
+
+ /** do not call before after type checking ends.
+ * Use <code>newName(Position, String)</code> instead.
+ */
+ @deprecated def newName(prefix: String): String
+
+ /** do not call before after type checking ends.
+ * Use newName(Position) instead.
+ */
+ @deprecated def newName(): String
+
+ def newName(pos: util.Position, prefix: String): String
+ def newName(pos: util.Position): String
}
+
object FreshNameCreator {
+
class Default extends FreshNameCreator {
- protected var counter = 0
- protected val counters = new HashMap[String, Int]
+ protected var counter = 0
+ protected val counters = new HashMap[String, Int]
- /**
- * Create a fresh name with the given prefix. It is guaranteed
- * that the returned name has never been returned by a previous
- * call to this function (provided the prefix does not end in a digit).
- */
- def newName(prefix: String): String = {
- val safePrefix = prefix.replace('<', '$').replace('>', '$')
- val count = counters.getOrElse(safePrefix, 0) + 1
- counters(safePrefix) = count
- safePrefix + count
- }
- def newName(pos : util.Position, prefix : String) = newName(prefix)
- def newName(pos : util.Position) = newName()
+ /**
+ * Create a fresh name with the given prefix. It is guaranteed
+ * that the returned name has never been returned by a previous
+ * call to this function (provided the prefix does not end in a digit).
+ */
+ def newName(prefix: String): String = {
+ val safePrefix = prefix.replace('<', '$').replace('>', '$')
+ val count = counters.getOrElse(safePrefix, 0) + 1
+ counters(safePrefix) = count
+ safePrefix + count
+ }
+ def newName(pos: util.Position, prefix: String) = newName(prefix)
+ def newName(pos: util.Position) = newName()
- def newName(): String = {
- counter = counter + 1
- "$" + counter + "$"
+ def newName(): String = {
+ counter += 1
+ "$" + counter + "$"
+ }
}
-}
+
}
diff --git a/src/library/scala/Application.scala b/src/library/scala/Application.scala
index aaec5f88c9..4321f8ed71 100644
--- a/src/library/scala/Application.scala
+++ b/src/library/scala/Application.scala
@@ -16,7 +16,8 @@ import scala.compat.Platform.currentTime
/** <p>
* The <code>Application</code> trait can be used to quickly turn objects
- * into executable programs, but is <em>not recommended</em>. Here is an example:
+ * into executable programs, but is <em>not recommended</em>.
+ * Here is an example:
* </p><pre>
* <b>object</b> Main <b>extends</b> Application {
* Console.println("Hello World!")
@@ -36,8 +37,10 @@ import scala.compat.Platform.currentTime
* </p><pre>
* java -Dscala.time Main
* </pre>
- * <p>In practice the <code>Application</code> trait has a number of serious
- * pitfalls:
+ * <p>
+ * In practice the <code>Application</code> trait has a number of serious
+ * pitfalls:
+ * </p>
* <ul>
* <li>As described above, there is no way to obtain the
* command-line arguments because all code in body of an <code>object</code>
@@ -55,7 +58,7 @@ import scala.compat.Platform.currentTime
* optimize or JIT the code in the body of an <code>object</code> extending
* <code>Application</code>. This can lead to a significant
* performance degradation.</li>
- * </p>
+ * </ul>
*
* @author Matthias Zenger
* @version 1.0, 10/09/2003
@@ -71,7 +74,7 @@ trait Application {
*
* @param args the arguments passed to the main method
*/
- def main(args: Array[String]) = {
+ def main(args: Array[String]) {
if (getProperty("scala.time") ne null) {
val total = currentTime - executionStart
Console.println("[total " + total + "ms]")
diff --git a/src/library/scala/Console.scala b/src/library/scala/Console.scala
index cb682c2310..d2a06e7e4a 100644
--- a/src/library/scala/Console.scala
+++ b/src/library/scala/Console.scala
@@ -106,7 +106,7 @@ object Console {
*
* @param reader specifies the new input stream.
*/
- def setIn(reader: Reader): Unit = {
+ def setIn(reader: Reader) {
inVar.value = new BufferedReader(reader)
}
@@ -125,8 +125,9 @@ object Console {
*
* @param in the new input stream.
*/
- def setIn(in: InputStream): Unit =
+ def setIn(in: InputStream) {
setIn(new InputStreamReader(in))
+ }
/** Set the default input stream for the duration
* of execution of one thunk.
@@ -142,8 +143,9 @@ object Console {
*
* @param obj the object to print.
*/
- def print(obj: Any): Unit =
+ def print(obj: Any) {
out.print(if (null == obj) "null" else obj.toString())
+ }
/** Flush the output stream. This function is required when partial
* output (i.e. output not terminated by a new line character) has
@@ -153,13 +155,13 @@ object Console {
/** Print a new line character on the terminal.
*/
- def println(): Unit = out.println()
+ def println() { out.println() }
/** Print out an object followed by a new line character.
*
* @param x the object to print.
*/
- def println(x: Any): Unit = out.println(x)
+ def println(x: Any) { out.println(x) }
/** <p>
* Prints its arguments as a formatted string, based on a string
@@ -183,8 +185,10 @@ object Console {
* @deprecated For console output, use <code>Console.printf</code>. For <code>String</code> formatting,
* <code>RichString</code>'s <code>format</code> method.
*/
- @deprecated def format(text: String, args: Any*) {
- if (text eq null) out.printf("null") else (out.print(text format (args : _*)))
+ @deprecated
+ def format(text: String, args: Any*) {
+ if (text eq null) out.printf("null")
+ else out.print(text format (args : _*))
}
/** Read a full line from the terminal. Returns <code>null</code> if the end of the
@@ -202,7 +206,7 @@ object Console {
* @return the string read from the terminal.
*/
def readLine(text: String, args: Any*): String = {
- format(text, args: _*)
+ printf(text, args: _*)
readLine()
}
@@ -214,17 +218,17 @@ object Console {
* @throws java.io.EOFException
*/
def readBoolean(): Boolean = {
- val s = readLine()
- if (s == null)
- throw new java.io.EOFException("Console has reached end of input")
- else
- s.toLowerCase() match {
- case "true" => true
- case "t" => true
- case "yes" => true
- case "y" => true
- case _ => false
- }
+ val s = readLine()
+ if (s == null)
+ throw new java.io.EOFException("Console has reached end of input")
+ else
+ s.toLowerCase() match {
+ case "true" => true
+ case "t" => true
+ case "yes" => true
+ case "y" => true
+ case _ => false
+ }
}
/** Read a byte value from the terminal.
diff --git a/src/library/scala/Seq.scala b/src/library/scala/Seq.scala
index 18b8dac676..656d3b6fab 100644
--- a/src/library/scala/Seq.scala
+++ b/src/library/scala/Seq.scala
@@ -301,7 +301,8 @@ trait Seq[+A] extends AnyRef with PartialFunction[Int, A] with Collection[A] {
* @param p the predicate used to filter the list.
* @return the elements of this list satisfying <code>p</code>.
*/
- override def filter(p: A => Boolean): Seq[A] = super.filter(p).asInstanceOf[Seq[A]]
+ override def filter(p: A => Boolean): Seq[A] =
+ super.filter(p).asInstanceOf[Seq[A]]
/** Returns a sequence consisting only over the first <code>n</code>
* elements of this sequence, or else the whole sequence, if it has less
@@ -366,7 +367,8 @@ trait Seq[+A] extends AnyRef with PartialFunction[Int, A] with Collection[A] {
* @return the longest prefix of this sequence whose elements satisfy
* the predicate <code>p</code>.
*/
- override def takeWhile(p: A => Boolean): Seq[A] = super.takeWhile(p).asInstanceOf[Seq[A]]
+ override def takeWhile(p: A => Boolean): Seq[A] =
+ super.takeWhile(p).asInstanceOf[Seq[A]]
/** Returns the longest suffix of this sequence whose first element
* does not satisfy the predicate <code>p</code>.
@@ -375,7 +377,8 @@ trait Seq[+A] extends AnyRef with PartialFunction[Int, A] with Collection[A] {
* @return the longest suffix of the sequence whose first element
* does not satisfy the predicate <code>p</code>.
*/
- override def dropWhile(p: A => Boolean): Seq[A] = super.dropWhile(p).asInstanceOf[Seq[A]]
+ override def dropWhile(p: A => Boolean): Seq[A] =
+ super.dropWhile(p).asInstanceOf[Seq[A]]
/** A sequence consisting of all elements of this sequence in reverse order.
*/
@@ -422,17 +425,18 @@ trait Seq[+A] extends AnyRef with PartialFunction[Int, A] with Collection[A] {
override def force: Seq[A] = Seq.this
def elements = Seq.this.elements
def length = Seq.this.length
- def apply(idx : Int) = (Seq.this.apply(idx))
+ def apply(idx: Int) = Seq.this.apply(idx)
override def stringPrefix = Seq.this.stringPrefix + "P"
}
- def equalsWith[B](that: Seq[B])(f: (A,B) => Boolean): Boolean = {
- if (size != that.size) return false
- val i = elements
- val j = that.elements
- while (i.hasNext) if (!f(i.next, j.next)) return false
- true
- }
+ def equalsWith[B](that: Seq[B])(f: (A,B) => Boolean): Boolean =
+ if (size != that.size) false
+ else {
+ val i = elements
+ val j = that.elements
+ while (i.hasNext) if (!f(i.next, j.next)) return false
+ true
+ }
/**
* Checks whether the argument sequence is contained at the
diff --git a/src/library/scala/SeqProxy.scala b/src/library/scala/SeqProxy.scala
index 7c7a286e83..915211b2e9 100644
--- a/src/library/scala/SeqProxy.scala
+++ b/src/library/scala/SeqProxy.scala
@@ -40,7 +40,8 @@ trait SeqProxy[+A] extends Seq[A] with CollectionProxy[A] {
override def lastOption = self.lastOption
override def first = self.first
override def firstOption = self.firstOption
- override def headOption = self.headOption
+ @deprecated
+ override def headOption = firstOption
override def ++ [B >: A](that: Iterable[B]) = self ++ that
override def isDefinedAt(x: Int): Boolean = self isDefinedAt x
@@ -57,7 +58,8 @@ trait SeqProxy[+A] extends Seq[A] with CollectionProxy[A] {
override def drop(n: Int): Seq[A] = self drop n
override def slice(from: Int, len: Int): Seq[A] = self.slice(from, len)
- override def slice(from: Int) = self slice from
+ @deprecated
+ override def slice(from: Int) = slice(from, length)
override def takeWhile(p: A => Boolean): Seq[A] = self takeWhile p
override def dropWhile(p: A => Boolean): Seq[A] = self dropWhile p
@@ -65,8 +67,8 @@ trait SeqProxy[+A] extends Seq[A] with CollectionProxy[A] {
override def reverse: Seq[A] = self.reverse
override def contains(elem: Any): Boolean = self contains elem
-
- override def subseq(from: Int, end: Int) = self.subseq(from, end)
+ @deprecated
+ override def subseq(from: Int, end: Int) = slice(from, end - from)
override def toArray[B >: A]: Array[B] = self.toArray
diff --git a/src/library/scala/collection/immutable/Stack.scala b/src/library/scala/collection/immutable/Stack.scala
index 4826048309..7aff093471 100644
--- a/src/library/scala/collection/immutable/Stack.scala
+++ b/src/library/scala/collection/immutable/Stack.scala
@@ -48,7 +48,8 @@ class Stack[+A] extends Seq[A] {
* @param elem the element to push on the stack.
* @return the stack with the new element on top.
*/
- @deprecated def +[B >: A](elem: B): Stack[B] = new Node(elem)
+ @deprecated
+ def +[B >: A](elem: B): Stack[B] = new Node(elem)
/** Push an element on the stack.
*
@@ -63,7 +64,7 @@ class Stack[+A] extends Seq[A] {
* @param elems the element sequence.
* @return the stack with the new elements on top.
*/
- def push[B >: A](elems: B*): Stack[B] = this + elems
+ def push[B >: A](elems: B*): Stack[B] = this ++ elems
/** Push all elements provided by the given iterable object onto
* the stack. The last element returned by the iterable object
@@ -74,7 +75,8 @@ class Stack[+A] extends Seq[A] {
* @param elems the iterable object.
* @return the stack with the new elements on top.
*/
- @deprecated def +[B >: A](elems: Iterable[B]): Stack[B] =
+ @deprecated
+ def +[B >: A](elems: Iterable[B]): Stack[B] =
elems.foldLeft(this: Stack[B]){ (stack, elem) => stack + elem }
/** Push all elements provided by the given iterable object onto
@@ -84,8 +86,7 @@ class Stack[+A] extends Seq[A] {
* @param elems the iterable object.
* @return the stack with the new elements on top.
*/
- def push[B >: A](elems: Iterable[B]): Stack[B] =
- this ++ elems
+ def push[B >: A](elems: Iterable[B]): Stack[B] = this ++ elems
/** Push all elements provided by the given iterator object onto
* the stack. The last element returned by the iterable object
diff --git a/src/library/scala/collection/immutable/TreeHashMap.scala b/src/library/scala/collection/immutable/TreeHashMap.scala
index 27f5112e0c..33915402ec 100644
--- a/src/library/scala/collection/immutable/TreeHashMap.scala
+++ b/src/library/scala/collection/immutable/TreeHashMap.scala
@@ -1,13 +1,14 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2008, David MacIver **
+** / __/ __// _ | / / / _ | (c) 2008-2009, David MacIver **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// $Id: $
-package scala.collection.immutable;
+
+package scala.collection.immutable
object TreeHashMap {
private[TreeHashMap] val _empty = new TreeHashMap[Any, Nothing](IntMap.empty[Nothing]);
@@ -45,15 +46,15 @@ class TreeHashMap[Key, +Value] private (private val underlying : IntMap[AssocMap
}
}
- def empty[V] = TreeHashMap.empty[Key, V];
+ def empty[V] = TreeHashMap.empty[Key, V]
- private def hash(key : Key) = {
+ private def hash(key : Key) = {
var h = key.hashCode;
h ^= ((h >>> 20) ^ (h >>> 12));
h ^ (h >>> 7) ^ (h >>> 4);
}
- override def stringPrefix="TreeHashMap"
+ override def stringPrefix = "TreeHashMap"
override lazy val size = underlying.values.foldLeft(0)((x, y) => x + y.size);
@@ -65,7 +66,7 @@ class TreeHashMap[Key, +Value] private (private val underlying : IntMap[AssocMap
case _ => false;
}
- override def hashCode = underlying.hashCode;
+ override def hashCode = underlying.hashCode
override def foreach(f : ((Key, Value)) => Unit) = underlying.foreachValue(_.foreach(f));
@@ -131,23 +132,24 @@ class TreeHashMap[Key, +Value] private (private val underlying : IntMap[AssocMap
}
-private [collection] object AssocMap{
- val _empty = Nil[Any];
+private [collection] object AssocMap {
+ val _empty = Nil[Any]
def empty[Key, Value] : AssocMap[Key, Value] = _empty.asInstanceOf[AssocMap[Key, Value]]
def singleton[Key, Value](key : Key, value : Value) = Cons(key, value, empty);
def apply[Key, Value](maps : (Key, Value)*) =
maps.foldLeft(empty[Key, Value])((x, y) => x.update(y._1, y._2));
- private[collection] case class Nil[Key] extends AssocMap[Key, Nothing];
- private[collection] case class Cons[S, +T](key : S, value : T, tail : AssocMap[S, T]) extends AssocMap[S, T]
+ private[collection] case class Nil[Key]() extends AssocMap[Key, Nothing]
+ private[collection] case class Cons[S, +T](key: S, value: T, tail: AssocMap[S, T]) extends AssocMap[S, T]
}
-import AssocMap._;
+import AssocMap._
-// AssocMap is very similar to ListMap. I don't want to patch ListMap right now, so I've got a separate
-// implementation here to make tweaks to. Long term any of these changes should be merged into ListMap
-// Short term it doesn't really matter because there are almost no viable use cases for ListMap compared
-// to one of the alternatives.
+// AssocMap is very similar to ListMap. I don't want to patch ListMap right
+// now, so I've got a separate implementation here to make tweaks to. Long
+// term any of these changes should be merged into ListMap
+// Short term it doesn't really matter because there are almost no viable
+// use cases for ListMap compared to one of the alternatives.
private[collection] sealed abstract class AssocMap[Key, +Value] extends immutable.Map[Key, Value]{
def empty[V] = AssocMap.empty[Key, V]
@@ -239,14 +241,14 @@ private[collection] sealed abstract class AssocMap[Key, +Value] extends immutabl
else Cons(key2, value2, tail.update(key, value));
}
- override def transform[C](f : (Key, Value) => C) : AssocMap[Key, C] = this match {
- case Nil() => AssocMap.empty[Key, C];
- case Cons(key, value, tail) => {
- val newtail = tail.transform(f);
- val newval = f(key, value);
+ override def transform[C](f: (Key, Value) => C): AssocMap[Key, C] = this match {
+ case Nil() =>
+ AssocMap.empty[Key, C]
+ case Cons(key, value, tail) =>
+ val newtail = tail.transform(f)
+ val newval = f(key, value)
if ((tail eq newtail) && (value.asInstanceOf[AnyRef] eq newval.asInstanceOf[AnyRef])) this.asInstanceOf[AssocMap[Key, C]];
else Cons(key, newval, newtail);
- }
}
def -(key : Key) : AssocMap[Key, Value]= this match {
diff --git a/src/library/scala/deprecated.scala b/src/library/scala/deprecated.scala
index e5321aefaa..cb152f1465 100644
--- a/src/library/scala/deprecated.scala
+++ b/src/library/scala/deprecated.scala
@@ -1,7 +1,7 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
diff --git a/src/library/scala/io/Position.scala b/src/library/scala/io/Position.scala
index 9ee868f5ca..4eec0e39d6 100644
--- a/src/library/scala/io/Position.scala
+++ b/src/library/scala/io/Position.scala
@@ -60,9 +60,6 @@ object Position {
/** The first position in a source file */
final val FIRSTPOS = encode(1, 1)
- //########################################################################
- // Public Functions
-
/** Encodes a position into a single integer. */
final def encode(line: Int, column: Int): Int = {
var line1, column1 = 0
@@ -73,17 +70,18 @@ object Position {
if (column < 0)
throw new IllegalArgumentException(line + "," + column + " not allowed")
- {if (line >= LINE_MASK) {
+ if (line >= LINE_MASK) {
line1 = LINE_MASK
column1 = 0
- } else {
+ }
+ else {
line1 = line
if (column > COLUMN_MASK)
column1 = COLUMN_MASK
else
column1 = column
- }}
- {(line1 << COLUMN_BITS) | column1;}
+ }
+ (line1 << COLUMN_BITS) | column1
}
/** Returns the line number of the encoded position. */
@@ -96,10 +94,10 @@ object Position {
/** Returns a string representation of the encoded position. */
def toString(pos: Int): String = {
- val sb = new StringBuilder()
- sb.append(line(pos))
- sb.append(':')
- sb.append(column(pos))
+ val sb = new StringBuilder
+ sb append line(pos)
+ sb append ':'
+ sb append column(pos)
sb.toString()
}
}
diff --git a/src/library/scala/io/Source.scala b/src/library/scala/io/Source.scala
index b97135f69c..3b79202b41 100644
--- a/src/library/scala/io/Source.scala
+++ b/src/library/scala/io/Source.scala
@@ -14,9 +14,9 @@ package scala.io
import java.io.{BufferedInputStream, File, FileInputStream, InputStream,
PrintStream}
+import java.net.{URI, URL}
import java.nio.{ByteBuffer, CharBuffer}
import java.nio.charset.Charset
-import java.net.{URI, URL}
/** This object provides convenience methods to create an iterable
* representation of a source file.
@@ -156,7 +156,7 @@ object Source {
fromURL(new URL(s), enc)
/**
- * @param url ...
+ * @param url the source URL
* @return ...
* @deprecated use fromURL(url, enc)
*/
@@ -192,13 +192,14 @@ object Source {
* @param enc the encoding to apply to the bytes
* @param maxlen optionally, a positive int specifying maximum number of bytes to read
*/
- @deprecated def fromInputStream(istream: InputStream, enc: String, maxlen: Option[Int]): Source = {
+ @deprecated
+ def fromInputStream(istream: InputStream, enc: String, maxlen: Option[Int]): Source = {
val limit = maxlen match { case Some(i) => i; case None => 0 }
val bi = new BufferedInputStream(istream, Source.DefaultBufSize)
val bytes = new collection.mutable.ArrayBuffer[Byte]()
var b = 0
var i = 0
- while( {b = bi.read; i += 1; b} != -1 && (limit <= 0 || i < limit)) {
+ while ( {b = bi.read; i += 1; b} != -1 && (limit <= 0 || i < limit)) {
bytes += b.toByte;
}
if(limit <= 0) bi.close
@@ -267,8 +268,8 @@ abstract class Source extends Iterator[Char] {
*/
def getLine(line: Int): String = { // faster than getLines.drop(line).next
// todo: should @throws scala.compat.Platform.IndexOutOfBoundsException
- if (line < 1) throw new IllegalArgumentException(line.toString);
- val buf = new StringBuilder()
+ if (line < 1) throw new IllegalArgumentException(line.toString)
+ val buf = new StringBuilder
val it = reset
var i = 0
@@ -279,7 +280,7 @@ abstract class Source extends Iterator[Char] {
if (!it.hasNext) // this should not happen
throw new IllegalArgumentException(
"line " + line + " does not exist"
- );
+ )
var ch = it.next
while (it.hasNext && '\n' != ch) {
@@ -302,11 +303,11 @@ abstract class Source extends Iterator[Char] {
val buf = new StringBuilder
def next = {
var ch = iter.next
- while(ch != '\n' && iter.hasNext) {
+ while (ch != '\n' && iter.hasNext) {
buf append ch
ch = iter.next
}
- buf.append(ch)
+ buf append ch
val res = buf.toString()
buf setLength 0 // clean things up for next call of "next"
res
@@ -320,9 +321,9 @@ abstract class Source extends Iterator[Char] {
/** returns next character and has the following side-effects: updates
* position (ccol and cline) and assigns the character to ch
*/
- def next = {
+ def next: Char = {
ch = iter.next
- pos = Position.encode(cline,ccol)
+ pos = Position.encode(cline, ccol)
ch match {
case '\n' =>
ccol = 1
@@ -337,26 +338,26 @@ abstract class Source extends Iterator[Char] {
/** Reports an error message to console.
*
- * @param pos ...
+ * @param pos the source position (line/column)
* @param msg the error message to report
*/
def reportError(pos: Int, msg: String) {
- reportError(pos, msg, java.lang.System.out)
+ reportError(pos, msg, Console.out)
}
/** Reports an error message to the output stream <code>out</code>.
*
- * @param pos ...
+ * @param pos the source position (line/column)
* @param msg the error message to report
* @param out ...
*/
def reportError(pos: Int, msg: String, out: PrintStream) {
- nerrors = nerrors + 1
+ nerrors += 1
report(pos, msg, out)
}
/**
- * @param pos ...
+ * @param pos the source position (line/column)
* @param msg the error message to report
* @param out ...
*/
@@ -365,32 +366,32 @@ abstract class Source extends Iterator[Char] {
val line = Position.line(pos)
val col = Position.column(pos)
buf.append(descr + ":" + line + ":" + col + ": " + msg)
- buf.append(getLine(line))
+ buf append getLine(line)
var i = 1
while (i < col) {
- buf.append(' ')
+ buf append ' '
i += 1
}
- buf.append('^')
+ buf append '^'
out.println(buf.toString)
}
- /** Reports a warning message to <code>java.lang.System.out</code>.
+ /** Reports a warning message to <code>Console.out</code>.
*
- * @param pos ...
+ * @param pos the source position (line/column)
* @param msg the warning message to report
*/
def reportWarning(pos: Int, msg: String) {
- reportWarning(pos, msg, java.lang.System.out)
+ reportWarning(pos, msg, Console.out)
}
/**
- * @param pos ...
+ * @param pos the source position (line/column)
* @param msg the warning message to report
* @param out ...
*/
def reportWarning(pos: Int, msg: String, out: PrintStream) {
- nwarnings = nwarnings + 1
+ nwarnings += 1
report(pos, "warning! " + msg, out)
}
diff --git a/src/library/scala/io/UTF8Codec.scala b/src/library/scala/io/UTF8Codec.scala
index 3d1d307c53..6d5e569971 100644
--- a/src/library/scala/io/UTF8Codec.scala
+++ b/src/library/scala/io/UTF8Codec.scala
@@ -28,7 +28,7 @@ object UTF8Codec {
val byteMask = 0xBF
val byteMark = 0x80
var bytesToWrite = 0
- val firstByteMark = List[Byte](0x00.asInstanceOf[Byte], 0x00.asInstanceOf[Byte], 0xC0.asInstanceOf[Byte], 0xE0.asInstanceOf[Byte], 0xF0.asInstanceOf[Byte], 0xF8.asInstanceOf[Byte], 0xFC.asInstanceOf[Byte])
+ val firstByteMark = List[Byte](0x00.toByte, 0x00.toByte, 0xC0.toByte, 0xE0.toByte, 0xF0.toByte, 0xF8.toByte, 0xFC.toByte)
if (ch < 0x80) { bytesToWrite = 1 }
else if (ch < 0x800) { bytesToWrite = 2 }
@@ -39,19 +39,19 @@ object UTF8Codec {
val res = new Array[Byte](bytesToWrite)
var bw = bytesToWrite
- if(bw>=4) {
- res(3) = ((ch | byteMark) & byteMask).asInstanceOf[Byte]; ch = ch >> 6; bw -= 1
+ if (bw >= 4) {
+ res(3) = ((ch | byteMark) & byteMask).toByte; ch = ch >> 6; bw -= 1
}
- if(bw>=3) {
- res(2) = ((ch | byteMark) & byteMask).asInstanceOf[Byte]; ch = ch >> 6; bw -= 1
+ if (bw >= 3) {
+ res(2) = ((ch | byteMark) & byteMask).toByte; ch = ch >> 6; bw -= 1
}
- if(bw>=2) {
- res(1) = ((ch | byteMark) & byteMask).asInstanceOf[Byte]; ch = ch >> 6; bw -= 1
+ if (bw >= 2) {
+ res(1) = ((ch | byteMark) & byteMask).toByte; ch = ch >> 6; bw -= 1
}
- if(bw>=1) {
- res(0) = (ch | firstByteMark(bytesToWrite)).asInstanceOf[Byte]
+ if (bw >= 1) {
+ res(0) = (ch | firstByteMark(bytesToWrite)).toByte
}
- return res
+ res
}
def encode(src: Array[Char], from: Int, dst: Array[Byte], to: Int, len: Int): Int = {
diff --git a/src/library/scala/remote.scala b/src/library/scala/remote.scala
index 6b377bc2e0..5208417807 100644
--- a/src/library/scala/remote.scala
+++ b/src/library/scala/remote.scala
@@ -1,7 +1,7 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
diff --git a/src/library/scala/util/Sorting.scala b/src/library/scala/util/Sorting.scala
index ab22314916..a7b740ce40 100644
--- a/src/library/scala/util/Sorting.scala
+++ b/src/library/scala/util/Sorting.scala
@@ -550,7 +550,7 @@ object Sorting {
5.785996973446602E9,
// 0.0/0.0,
3.973064849653333E10,
- 3.724737288678125E10,
+ 3.724737288678125E10
// 0.0/0.0
)
val floats = Array(
@@ -561,7 +561,7 @@ object Sorting {
5.785996973446602E9f,
// 0.0f/0.0f,
3.973064849653333E10f,
- 3.724737288678125E10f,
+ 3.724737288678125E10f
// 0.0f/0.0f
)
Sorting quickSort tuples
diff --git a/src/partest/scala/tools/partest/PartestTask.scala b/src/partest/scala/tools/partest/PartestTask.scala
index b619eaa9ca..bda1f5b679 100644
--- a/src/partest/scala/tools/partest/PartestTask.scala
+++ b/src/partest/scala/tools/partest/PartestTask.scala
@@ -20,70 +20,89 @@ import org.apache.tools.ant.types.{Path, Reference, FileSet}
class PartestTask extends Task {
- def addConfiguredPosTests(input: FileSet): Unit =
+ def addConfiguredPosTests(input: FileSet) {
posFiles = Some(input)
+ }
- def addConfiguredPos5Tests(input: FileSet): Unit =
+ def addConfiguredPos5Tests(input: FileSet) {
pos5Files = Some(input)
+ }
- def addConfiguredNegTests(input: FileSet): Unit =
+ def addConfiguredNegTests(input: FileSet) {
negFiles = Some(input)
+ }
- def addConfiguredRunTests(input: FileSet): Unit =
+ def addConfiguredRunTests(input: FileSet) {
runFiles = Some(input)
+ }
- def addConfiguredJvmTests(input: FileSet): Unit =
+ def addConfiguredJvmTests(input: FileSet) {
jvmFiles = Some(input)
+ }
- def addConfiguredJvm5Tests(input: FileSet): Unit =
+ def addConfiguredJvm5Tests(input: FileSet) {
jvm5Files = Some(input)
+ }
- def addConfiguredResidentTests(input: FileSet): Unit =
+ def addConfiguredResidentTests(input: FileSet) {
residentFiles = Some(input)
+ }
- def addConfiguredScriptTests(input: FileSet): Unit =
+ def addConfiguredScriptTests(input: FileSet) {
scriptFiles = Some(input)
+ }
- def addConfiguredShootoutTests(input: FileSet): Unit =
+ def addConfiguredShootoutTests(input: FileSet) {
shootoutFiles = Some(input)
+ }
- def setClasspath(input: Path): Unit =
+ def setClasspath(input: Path) {
if (classpath.isEmpty)
classpath = Some(input)
else
classpath.get.append(input)
+ }
def createClasspath(): Path = {
if (classpath.isEmpty) classpath = Some(new Path(getProject()))
classpath.get.createPath()
}
- def setClasspathref(input: Reference): Unit =
+ def setClasspathref(input: Reference) {
createClasspath().setRefid(input)
+ }
- def setShowLog(input: Boolean): Unit =
+ def setShowLog(input: Boolean) {
showLog = input
+ }
- def setShowDiff(input: Boolean): Unit =
+ def setShowDiff(input: Boolean) {
showDiff = input
+ }
- def setErrorOnFailed(input: Boolean): Unit =
+ def setErrorOnFailed(input: Boolean) {
errorOnFailed = input
+ }
- def setJavaCmd(input: File): Unit =
+ def setJavaCmd(input: File) {
javacmd = Some(input)
+ }
- def setJavacCmd(input: File): Unit =
+ def setJavacCmd(input: File) {
javaccmd = Some(input)
+ }
- def setScalacOpts(opts: String): Unit =
+ def setScalacOpts(opts: String) {
scalacOpts = Some(opts)
+ }
- def setTimeout(delay: String): Unit =
+ def setTimeout(delay: String) {
timeout = Some(delay)
+ }
- def setDebug(input: Boolean): Unit =
+ def setDebug(input: Boolean) {
debug = input
+ }
private var classpath: Option[Path] = None
private var javacmd: Option[File] = None
@@ -105,12 +124,20 @@ class PartestTask extends Task {
private var timeout: Option[String] = None
private var debug = false
+ private def getFiles(fileSet: Option[FileSet]): Array[File] =
+ if (fileSet.isEmpty) Array()
+ else {
+ val files = fileSet.get
+ files.getDirectoryScanner(getProject).getIncludedFiles map {
+ fs => new File(files.getDir(getProject), fs)
+ }
+ }
+
private def getFilesAndDirs(fileSet: Option[FileSet]): Array[File] =
if (!fileSet.isEmpty) {
val files = fileSet.get
+ val fileTests = getFiles(fileSet)
val dir = files.getDir(getProject)
- val fileTests = (files.getDirectoryScanner(getProject).getIncludedFiles map { fs =>
- new File(dir, fs) })
val dirTests = dir.listFiles(new java.io.FileFilter {
def accept(file: File) =
file.isDirectory &&
@@ -122,59 +149,17 @@ class PartestTask extends Task {
else
Array()
- private def getPosFiles: Array[File] =
- getFilesAndDirs(posFiles)
-
- private def getPos5Files: Array[File] =
- getFilesAndDirs(pos5Files)
-
- private def getNegFiles: Array[File] =
- if (!negFiles.isEmpty) {
- val files = negFiles.get
- (files.getDirectoryScanner(getProject).getIncludedFiles map { fs => new File(files.getDir(getProject), fs) })
- }
- else
- Array()
-
- private def getRunFiles: Array[File] =
- if (!runFiles.isEmpty) {
- val files = runFiles.get
- (files.getDirectoryScanner(getProject).getIncludedFiles map { fs => new File(files.getDir(getProject), fs) })
- }
- else
- Array()
-
- private def getJvmFiles: Array[File] =
- getFilesAndDirs(jvmFiles)
-
- private def getJvm5Files: Array[File] =
- getFilesAndDirs(jvm5Files)
-
- private def getResidentFiles: Array[File] =
- if (!residentFiles.isEmpty) {
- val files = residentFiles.get
- (files.getDirectoryScanner(getProject).getIncludedFiles map { fs => new File(files.getDir(getProject), fs) })
- }
- else
- Array()
-
- private def getScriptFiles: Array[File] =
- if (!scriptFiles.isEmpty) {
- val files = scriptFiles.get
- (files.getDirectoryScanner(getProject).getIncludedFiles map { fs => new File(files.getDir(getProject), fs) })
- }
- else
- Array()
-
- private def getShootoutFiles: Array[File] =
- if (!shootoutFiles.isEmpty) {
- val files = shootoutFiles.get
- (files.getDirectoryScanner(getProject).getIncludedFiles map { fs => new File(files.getDir(getProject), fs) })
- }
- else
- Array()
-
- override def execute(): Unit = {
+ private def getPosFiles = getFilesAndDirs(posFiles)
+ private def getPos5Files = getFilesAndDirs(pos5Files)
+ private def getNegFiles = getFiles(negFiles)
+ private def getRunFiles = getFiles(runFiles)
+ private def getJvmFiles = getFilesAndDirs(jvmFiles)
+ private def getJvm5Files = getFilesAndDirs(jvm5Files)
+ private def getResidentFiles = getFiles(residentFiles)
+ private def getScriptFiles = getFiles(scriptFiles)
+ private def getShootoutFiles = getFiles(shootoutFiles)
+
+ override def execute() {
if (debug)
System.setProperty("partest.debug", "true")
@@ -208,13 +193,13 @@ class PartestTask extends Task {
(result >> 16, result & 0x00FF)
}
- def setFileManagerBooleanProperty(name: String, value: Boolean) = {
+ def setFileManagerBooleanProperty(name: String, value: Boolean) {
val setMethod =
antFileManager.getClass.getMethod(name+"_$eq", Array(classOf[Boolean]): _*)
setMethod.invoke(antFileManager, Array(java.lang.Boolean.valueOf(value)): _*)
}
- def setFileManagerStringProperty(name: String, value: String) = {
+ def setFileManagerStringProperty(name: String, value: String) {
val setMethod =
antFileManager.getClass.getMethod(name+"_$eq", Array(classOf[String]): _*)
setMethod.invoke(antFileManager, Array(value): _*)
@@ -304,11 +289,11 @@ class PartestTask extends Task {
log("There where no tests to run.")
else if (allFailures == 0)
log("Test suite finished with no failures.")
- else if (errorOnFailed)
- error("Test suite finished with " + allFailures + " case" + (if (allFailures > 1) "s" else "") + " failing.")
- else
- log("Test suite finished with " + allFailures + " case" + (if (allFailures > 1) "s" else "") + " failing.")
-
+ else {
+ val msg = "Test suite finished with " + allFailures +
+ " case" + (if (allFailures > 1) "s" else "") + " failing."
+ if (errorOnFailed) error(msg) else log(msg)
+ }
}
}
diff --git a/src/partest/scala/tools/partest/nest/AntRunner.scala b/src/partest/scala/tools/partest/nest/AntRunner.scala
index 8b0a6c1c2b..9939a6b0c3 100644
--- a/src/partest/scala/tools/partest/nest/AntRunner.scala
+++ b/src/partest/scala/tools/partest/nest/AntRunner.scala
@@ -10,24 +10,17 @@
package scala.tools.partest.nest
-import scala.actors.Actor._
-
import java.io.File
-import java.net.URLClassLoader
-
-import org.apache.tools.ant.Task
-import org.apache.tools.ant.types.{Path, Reference, FileSet}
class AntRunner extends DirectRunner {
val fileManager = new FileManager {
-
var JAVACMD: String = "java"
var JAVAC_CMD: String = "javac"
var CLASSPATH: String = _
var EXT_CLASSPATH: String = _
var LATEST_LIB: String = _
-
+ val TESTROOT: String = ""
}
def reflectiveRunTestsForFiles(kindFiles: Array[File], kind: String): Int = {
diff --git a/src/partest/scala/tools/partest/nest/CompileManager.scala b/src/partest/scala/tools/partest/nest/CompileManager.scala
index f1fa7ccde2..a9a930462a 100644
--- a/src/partest/scala/tools/partest/nest/CompileManager.scala
+++ b/src/partest/scala/tools/partest/nest/CompileManager.scala
@@ -55,6 +55,25 @@ class DirectCompiler(val fileManager: FileManager) extends SimpleCompiler {
Console.in,
new PrintWriter(new StringWriter))
+ private def updatePluginPath(options: String): String = {
+ val (opt1, opt2) =
+ (options split "\\s").toList partition (_ startsWith "-Xplugin:")
+ (opt2 mkString " ")+(
+ if (opt1.isEmpty) ""
+ else {
+ def absolutize(path: String): List[String] = {
+ val args = (path substring 9 split File.pathSeparator).toList
+ val plugins = args map (arg =>
+ if (new File(arg).isAbsolute) arg
+ else fileManager.TESTROOT+File.separator+arg
+ )
+ plugins
+ }
+ " -Xplugin:"+((opt1 flatMap absolutize) mkString File.pathSeparator)
+ }
+ )
+ }
+
def compile(out: Option[File], files: List[File], kind: String, log: File): Boolean = {
val testSettings = newSettings
val logWriter = new FileWriter(log)
@@ -68,13 +87,13 @@ class DirectCompiler(val fileManager: FileManager) extends SimpleCompiler {
val argString = if (argsFile.exists) {
val fileReader = new FileReader(argsFile)
val reader = new BufferedReader(fileReader)
- val options = reader.readLine()
+ val options = updatePluginPath(reader.readLine())
reader.close()
options
} else ""
val allOpts = fileManager.SCALAC_OPTS+" "+argString
NestUI.verbose("scalac options: "+allOpts)
- val args = List.fromArray(allOpts.split("\\s"))
+ val args = List.fromArray(allOpts split "\\s")
val command = new CompilerCommand(args, testSettings, x => {}, false)
val global = newGlobal(command.settings, logWriter)
val testRep: ExtConsoleReporter = global.reporter.asInstanceOf[ExtConsoleReporter]
diff --git a/src/partest/scala/tools/partest/nest/ConsoleRunner.scala b/src/partest/scala/tools/partest/nest/ConsoleRunner.scala
index c889f88311..f85f16efec 100644
--- a/src/partest/scala/tools/partest/nest/ConsoleRunner.scala
+++ b/src/partest/scala/tools/partest/nest/ConsoleRunner.scala
@@ -54,9 +54,17 @@ class ConsoleRunner extends DirectRunner with RunnerUtils {
def denotesTestDir(arg: String) =
(new File(arg)).isDirectory
+ private def printVersion {
+ val versionMsg = "Scala partest "+
+ NestUI.versionString+
+ " -- "+
+ scala.tools.nsc.Properties.copyrightString
+ NestUI.outline(versionMsg+"\n")
+ }
+
def main(argstr: String) {
// tokenize args. filter: "".split("\\s") yields Array("")
- var args = List.fromArray(argstr.split("\\s")).remove(_ == "")
+ var args = List.fromArray(argstr split "\\s").remove(_ == "")
if (args.length == 0)
NestUI.usage()
@@ -100,7 +108,7 @@ class ConsoleRunner extends DirectRunner with RunnerUtils {
case "--show-diff" => fileManager.showDiff = true
case "--show-log" => fileManager.showLog = true
case "--failed" => fileManager.failed = true
- case "--version" => //todo: printVersion
+ case "--version" => printVersion; return
case "--ansi" => NestUI.initialize(NestUI.MANY)
case "--timeout" => readTimeout = true
case s: String if readTimeout =>
diff --git a/src/partest/scala/tools/partest/nest/FileManager.scala b/src/partest/scala/tools/partest/nest/FileManager.scala
index 740982ac0a..625173b767 100644
--- a/src/partest/scala/tools/partest/nest/FileManager.scala
+++ b/src/partest/scala/tools/partest/nest/FileManager.scala
@@ -39,7 +39,7 @@ trait FileManager {
val args = Array(f1.getCanonicalPath(), f2.getCanonicalPath())
DiffPrint.doDiff(args, diffWriter)
res = diffWriter.toString
- if (res.startsWith("No"))
+ if (res startsWith "No")
res = ""
} catch {
case e: IOException =>
@@ -48,7 +48,6 @@ trait FileManager {
res
}
-
var JAVACMD: String
var JAVAC_CMD: String
@@ -56,6 +55,8 @@ trait FileManager {
var LATEST_LIB: String
var LIB_DIR: String = ""
+ val TESTROOT: String
+
var showDiff = false
var showLog = false
var failed = false
diff --git a/src/partest/scala/tools/partest/nest/NestUI.scala b/src/partest/scala/tools/partest/nest/NestUI.scala
index ecddd8d946..4dcebf8a41 100644
--- a/src/partest/scala/tools/partest/nest/NestUI.scala
+++ b/src/partest/scala/tools/partest/nest/NestUI.scala
@@ -1,4 +1,5 @@
/* NEST (New Scala Test)
+ * Copyright 2007-2009 LAMP/EPFL
* @author Philipp Haller
*/
@@ -10,6 +11,9 @@ import java.io.PrintWriter
object NestUI {
+ val versionString =
+ System.getProperty("partest.version", "version 0.9.2")
+
val NONE = 0
val SOME = 1
val MANY = 2
@@ -91,12 +95,11 @@ object NestUI {
println(" --srcpath set (relative) path to test source files")
println(" ex.: --srcpath pending")
println
- println("version 0.9.2")
+ println(versionString)
println("maintained by Philipp Haller (EPFL)")
exit(1)
}
-
var _verbose = false
def verbose(msg: String) {
diff --git a/src/partest/scala/tools/partest/nest/RunnerUtils.scala b/src/partest/scala/tools/partest/nest/RunnerUtils.scala
index 2cfee0aaf1..12d0fcd217 100644
--- a/src/partest/scala/tools/partest/nest/RunnerUtils.scala
+++ b/src/partest/scala/tools/partest/nest/RunnerUtils.scala
@@ -1,3 +1,9 @@
+/* NEST (New Scala Test)
+ * Copyright 2007-2009 LAMP/EPFL
+ * @author Philipp Haller
+ */
+
+// $Id$
package scala.tools.partest.nest
diff --git a/src/partest/scala/tools/partest/nest/Worker.scala b/src/partest/scala/tools/partest/nest/Worker.scala
index 80fd3e0eba..b1e83d6808 100644
--- a/src/partest/scala/tools/partest/nest/Worker.scala
+++ b/src/partest/scala/tools/partest/nest/Worker.scala
@@ -1,4 +1,5 @@
/* NEST (New Scala Test)
+ * Copyright 2007-2009 LAMP/EPFL
* @author Philipp Haller
*/
@@ -328,7 +329,7 @@ class Worker(val fileManager: FileManager) extends Actor {
* @param kind The test kind (pos, neg, run, etc.)
* @param files The list of test files
*/
- def runTests(kind: String, files: List[File], topcont: (Int, Int) => Unit): Unit = {
+ def runTests(kind: String, files: List[File], topcont: (Int, Int) => Unit) {
val compileMgr = new CompileManager(fileManager)
var errors = 0
var succeeded = true
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 94a15b1c85..08a3e1795b 100644
--- a/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSigPrinter.scala
+++ b/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSigPrinter.scala
@@ -1,10 +1,20 @@
+/* ___ ____ ___ __ ___ ___
+** / _// __// _ | / / / _ | / _ \ Scala classfile decoder
+** __\ \/ /__/ __ |/ /__/ __ |/ ___/ (c) 2003-2009, LAMP/EPFL
+** /____/\___/_/ |_/____/_/ |_/_/ http://scala-lang.org/
+**
+*/
+
+// $Id$
+
package scala.tools.scalap.scalax.rules.scalasig
-import _root_.scala.Symbol
import java.io.{PrintStream, ByteArrayOutputStream}
-import util.StringUtil
import java.util.regex.Pattern
+import _root_.scala.Symbol
+import scala.tools.scalap.scalax.util.StringUtil
+
class ScalaSigPrinter(stream: PrintStream, printPrivates: Boolean) {
import stream._
@@ -12,7 +22,7 @@ class ScalaSigPrinter(stream: PrintStream, printPrivates: Boolean) {
case class TypeFlags(printRep: Boolean)
- def printSymbol(symbol: Symbol) {printSymbol(0, symbol)}
+ def printSymbol(symbol: Symbol) { printSymbol(0, symbol) }
def printSymbol(level: Int, symbol: Symbol) {
if (!symbol.isLocal &&
@@ -20,17 +30,22 @@ class ScalaSigPrinter(stream: PrintStream, printPrivates: Boolean) {
def indent() {for (i <- 1 to level) print(" ")}
symbol match {
- case o: ObjectSymbol => if (!isCaseClassObject(o)) {
+ case o: ObjectSymbol =>
+ if (!isCaseClassObject(o)) {
+ indent
+ printObject(level, o)
+ }
+ case c: ClassSymbol if !refinementClass(c) && !c.isModule =>
indent
- printObject(level, o)
- }
- case c: ClassSymbol if !refinementClass(c) && !c.isModule => indent; {
printClass(level, c)
- }
- case m: MethodSymbol => printMethod(level, m, indent)
- case a: AliasSymbol => indent; printAlias(level, a)
- case t: TypeSymbol => ()
- case s => {}
+ case m: MethodSymbol =>
+ printMethod(level, m, indent)
+ case a: AliasSymbol =>
+ indent
+ printAlias(level, a)
+ case t: TypeSymbol =>
+ ()
+ case s =>
}
}
}
@@ -43,13 +58,13 @@ class ScalaSigPrinter(stream: PrintStream, printPrivates: Boolean) {
})
}
- def underCaseClass(m: MethodSymbol) = m.parent match {
+ private def underCaseClass(m: MethodSymbol) = m.parent match {
case Some(c: ClassSymbol) => c.isCase
case _ => false
}
- def printChildren(level: Int, symbol: Symbol) {
+ private def printChildren(level: Int, symbol: Symbol) {
for (child <- symbol.children) printSymbol(level + 1, child)
}
@@ -102,14 +117,14 @@ class ScalaSigPrinter(stream: PrintStream, printPrivates: Boolean) {
case m : MethodSymbol if m.name == CONSTRUCTOR_NAME => true
case _ => false
} match {
- case Some(m: MethodSymbol) => {
+ case Some(m: MethodSymbol) =>
val baos = new ByteArrayOutputStream
val stream = new PrintStream(baos)
val printer = new ScalaSigPrinter(stream, printPrivates)
printer.printMethodType(m.infoType, false)
baos.toString
- }
- case None => ""
+ case None =>
+ ""
}
}
@@ -160,7 +175,7 @@ class ScalaSigPrinter(stream: PrintStream, printPrivates: Boolean) {
}
}
- def printMethod(level: Int, m: MethodSymbol, indent : () => Unit): Unit = {
+ def printMethod(level: Int, m: MethodSymbol, indent: () => Unit) {
val n = m.name
if (underCaseClass(m) && n == CONSTRUCTOR_NAME) return
if (m.isAccessor && n.endsWith("_$eq")) return
@@ -174,19 +189,17 @@ class ScalaSigPrinter(stream: PrintStream, printPrivates: Boolean) {
print("def ")
}
n match {
- case CONSTRUCTOR_NAME => {
+ case CONSTRUCTOR_NAME =>
print("this")
printMethodType(m.infoType, false)
print(" = { /* compiled code */ }")
- }
- case name => {
+ case name =>
val nn = processName(name)
print(nn)
printMethodType(m.infoType, true)
if (!m.isDeferred) { // Print body only for non-abstract metods
print(" = { /* compiled code */ }")
}
- }
}
print("\n")
printChildren(level, m)