summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc
diff options
context:
space:
mode:
authormihaylov <mihaylov@epfl.ch>2006-11-01 16:03:28 +0000
committermihaylov <mihaylov@epfl.ch>2006-11-01 16:03:28 +0000
commit257a1845d3db3477a0b5939e94d77b0495d89561 (patch)
tree0aedf35621282407918e0f56b3b5ffc0952e6a14 /src/compiler/scala/tools/nsc
parent8b0cd5cf7c2a682dd70d6b8ea32b521015bf2269 (diff)
downloadscala-257a1845d3db3477a0b5939e94d77b0495d89561.tar.gz
scala-257a1845d3db3477a0b5939e94d77b0495d89561.tar.bz2
scala-257a1845d3db3477a0b5939e94d77b0495d89561.zip
Refactored portability support
Diffstat (limited to 'src/compiler/scala/tools/nsc')
-rw-r--r--src/compiler/scala/tools/nsc/CompileClient.scala27
-rw-r--r--src/compiler/scala/tools/nsc/CompileServer.scala6
-rw-r--r--src/compiler/scala/tools/nsc/CompileSocket.scala9
-rw-r--r--src/compiler/scala/tools/nsc/CompilerCommand.scala4
-rw-r--r--src/compiler/scala/tools/nsc/GenericRunnerSettings.scala4
-rw-r--r--src/compiler/scala/tools/nsc/Global.scala11
-rw-r--r--src/compiler/scala/tools/nsc/Interpreter.scala3
-rw-r--r--src/compiler/scala/tools/nsc/InterpreterLoop.scala2
-rw-r--r--src/compiler/scala/tools/nsc/Main.scala14
-rw-r--r--src/compiler/scala/tools/nsc/MainGenericRunner.scala7
-rw-r--r--src/compiler/scala/tools/nsc/MainTokenMetric.scala6
-rw-r--r--src/compiler/scala/tools/nsc/ObjectRunner.scala2
-rw-r--r--src/compiler/scala/tools/nsc/ScriptRunner.scala5
-rw-r--r--src/compiler/scala/tools/nsc/Settings.scala1
-rw-r--r--src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala5
-rw-r--r--src/compiler/scala/tools/nsc/ast/TreePrinters.scala6
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala19
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Scanners.scala9
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala9
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/Checkers.scala4
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/GenICode.scala3
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/ICodes.scala4
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala3
-rw-r--r--src/compiler/scala/tools/nsc/doc/DocGenerator.scala3
-rw-r--r--src/compiler/scala/tools/nsc/io/AbstractFile.scala2
-rw-r--r--src/compiler/scala/tools/nsc/io/VirtualFile.scala3
-rw-r--r--src/compiler/scala/tools/nsc/matching/PatternMatchers.scala11
-rw-r--r--src/compiler/scala/tools/nsc/matching/PatternNodes.scala9
-rw-r--r--src/compiler/scala/tools/nsc/models/Models.scala10
-rw-r--r--src/compiler/scala/tools/nsc/models/SemanticTokens.scala122
-rw-r--r--src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala10
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Constants.scala10
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Definitions.scala8
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Names.scala4
-rw-r--r--src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala3
-rw-r--r--src/compiler/scala/tools/nsc/symtab/SymbolTable.scala2
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Symbols.scala4
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Types.scala45
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/AbstractFileReader.scala8
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala15
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/PickleBuffer.scala4
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala2
-rw-r--r--src/compiler/scala/tools/nsc/transform/Erasure.scala10
-rw-r--r--src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala2
-rw-r--r--src/compiler/scala/tools/nsc/transform/LambdaLift.scala2
-rw-r--r--src/compiler/scala/tools/nsc/transform/Mixin.scala4
-rw-r--r--src/compiler/scala/tools/nsc/transform/UnCurry.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/ConstantFolder.scala3
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Infer.scala20
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Namers.scala6
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala26
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala4
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala6
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala39
-rw-r--r--src/compiler/scala/tools/nsc/util/ClassPath.scala8
-rw-r--r--src/compiler/scala/tools/nsc/util/HashSet.scala4
-rw-r--r--src/compiler/scala/tools/nsc/util/NameTransformer.scala10
-rw-r--r--src/compiler/scala/tools/nsc/util/Position.scala5
-rw-r--r--src/compiler/scala/tools/nsc/util/ShowPickled.scala15
-rw-r--r--src/compiler/scala/tools/nsc/util/SourceFile.scala7
61 files changed, 335 insertions, 278 deletions
diff --git a/src/compiler/scala/tools/nsc/CompileClient.scala b/src/compiler/scala/tools/nsc/CompileClient.scala
index 552c4b3644..ada6f83ea4 100644
--- a/src/compiler/scala/tools/nsc/CompileClient.scala
+++ b/src/compiler/scala/tools/nsc/CompileClient.scala
@@ -6,19 +6,20 @@
package scala.tools.nsc
+import java.lang.System.getProperty
+import java.io.File
+import java.io.PrintWriter
+import java.io.{BufferedReader, InputStreamReader}
import scala.tools.util.StringOps
-import java.io._
+import compat.StringBuilder
/** The main class for NSC, a compiler for the programming
* language Scala.
*/
object CompileClient {
- val PRODUCT: String =
- System.getProperty("scala.tool.name", "scalac")
- val VERSION: String =
- System.getProperty("scala.tool.version", "unknown version")
- val COPYRIGHT: String =
- System.getProperty("scala.copyright", "(c) 2002-2006 LAMP/EPFL")
+ val PRODUCT: String = getProperty("scala.tool.name", "scalac")
+ val VERSION: String = getProperty("scala.tool.version", "unknown version")
+ val COPYRIGHT: String = getProperty("scala.copyright", "(c) 2002-2006 LAMP/EPFL")
val versionMsg = PRODUCT + " " + VERSION + " -- " + COPYRIGHT
@@ -39,7 +40,7 @@ object CompileClient {
def normalize(args: Array[String]): Pair[String, String] = {
var i = 0
- val vmArgs = new StringBuffer
+ val vmArgs = new StringBuilder
var serverAdr = ""
while (i < args.length) {
val arg = args(i)
@@ -82,12 +83,12 @@ object CompileClient {
val Pair(vmArgs, serverAdr) = normalize(args)
if(version) {
- System.out.println(versionMsg)
+ Console.println(versionMsg)
return
}
if (verbose) {
- System.out.println("[Server arguments: " + args.mkString("", " ", "]"))
- System.out.println("[VM arguments: " + vmArgs + "]")
+ Console.println("[Server arguments: " + args.mkString("", " ", "]"))
+ Console.println("[VM arguments: " + vmArgs + "]")
}
val socket = if (serverAdr == "") CompileSocket.getOrCreateSocket(vmArgs)
else CompileSocket.getSocket(serverAdr)
@@ -100,13 +101,13 @@ object CompileClient {
while (fromServer != null) {
if(CompileSocket.errorPattern.matcher(fromServer).matches)
sawerror = true
- System.out.println(fromServer)
+ Console.println(fromServer)
fromServer = in.readLine()
}
in.close()
out.close()
socket.close()
- System.exit(if (sawerror) 1 else 0)
+ exit(if (sawerror) 1 else 0)
}
}
diff --git a/src/compiler/scala/tools/nsc/CompileServer.scala b/src/compiler/scala/tools/nsc/CompileServer.scala
index 8d940f39c3..d407dd111a 100644
--- a/src/compiler/scala/tools/nsc/CompileServer.scala
+++ b/src/compiler/scala/tools/nsc/CompileServer.scala
@@ -11,7 +11,11 @@ import scala.tools.nsc.util.FakePos //Position
import scala.tools.nsc.reporters.{Reporter, ConsoleReporter}
import scala.tools.nsc.doc.DocGenerator
import scala.concurrent.Process.spawn
-import java.io._
+import java.lang.System
+import java.lang.Thread
+import java.lang.Runtime
+import java.io.File
+import java.io.{PrintStream, BufferedOutputStream, FileOutputStream}
/** The main class for NSC, a compiler for the programming
* language Scala.
diff --git a/src/compiler/scala/tools/nsc/CompileSocket.scala b/src/compiler/scala/tools/nsc/CompileSocket.scala
index 1c600a1a38..d326aa433f 100644
--- a/src/compiler/scala/tools/nsc/CompileSocket.scala
+++ b/src/compiler/scala/tools/nsc/CompileSocket.scala
@@ -6,7 +6,10 @@
package scala.tools.nsc
-import java.io._
+import java.lang.{Thread, System, Runtime}
+import java.lang.NumberFormatException
+import java.io.{File, IOException, PrintWriter, FileOutputStream}
+import java.io.{BufferedReader, FileReader}
import java.net._
object CompileSocket {
@@ -131,7 +134,7 @@ object CompileSocket {
else
try {
for (val i <- 1 until hits.length) hits(i).delete()
- Integer.parseInt(hits(0).getName)
+ hits(0).getName.toInt
} catch {
case ex: NumberFormatException =>
fatal(ex.toString() +
@@ -209,7 +212,7 @@ object CompileSocket {
else {
val hostName = serverAdr.substring(0, cpos)
val port = try {
- Integer.parseInt(serverAdr.substring(cpos+1))
+ serverAdr.substring(cpos+1).toInt
} catch {
case ex: Throwable =>
fatal("Malformed server address: " + serverAdr + "; exiting")
diff --git a/src/compiler/scala/tools/nsc/CompilerCommand.scala b/src/compiler/scala/tools/nsc/CompilerCommand.scala
index 23e1b122be..d5bd523efa 100644
--- a/src/compiler/scala/tools/nsc/CompilerCommand.scala
+++ b/src/compiler/scala/tools/nsc/CompilerCommand.scala
@@ -7,6 +7,8 @@
package scala.tools.nsc
+import compat.StringBuilder
+
/** A class representing command line info for scalac */
class CompilerCommand(arguments: List[String], error: String => unit, interactive: boolean) {
private var fs: List[String] = List()
@@ -28,7 +30,7 @@ class CompilerCommand(arguments: List[String], error: String => unit, interactiv
val helpSyntaxColumnWidth: int =
Iterable.max(settings.allSettings map (. helpSyntax.length()))
def format(s: String): String = {
- val buf = new StringBuffer(s)
+ val buf = new StringBuilder(s)
var i = s.length()
while (i < helpSyntaxColumnWidth) { buf.append(' '); i = i + 1 }
buf.toString()
diff --git a/src/compiler/scala/tools/nsc/GenericRunnerSettings.scala b/src/compiler/scala/tools/nsc/GenericRunnerSettings.scala
index 65b6745edd..4503abf241 100644
--- a/src/compiler/scala/tools/nsc/GenericRunnerSettings.scala
+++ b/src/compiler/scala/tools/nsc/GenericRunnerSettings.scala
@@ -6,6 +6,8 @@
// $Id$
package scala.tools.nsc
+
+import java.lang.System.getProperties
import scala.collection.mutable.Queue
class GenericRunnerSettings(error: String => Unit)
@@ -60,7 +62,7 @@ extends Settings(error) {
/** Apply the specified properties to the current JVM */
def applyToCurrentJVM = {
- val systemProps = System.getProperties
+ val systemProps = getProperties
for(val Pair(key, value) <- props.toList)
systemProps.setProperty(key, value)
}
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala
index 5907c217a7..3a0e38c5c0 100644
--- a/src/compiler/scala/tools/nsc/Global.scala
+++ b/src/compiler/scala/tools/nsc/Global.scala
@@ -8,6 +8,7 @@ package scala.tools.nsc
import java.io._
import java.nio.charset._
+import compat.Platform.currentTime
import scala.tools.nsc.io.{SourceReader, AbstractFile}
import scala.tools.nsc.util.ClassPath
import scala.tools.nsc.util.{Position, SourceFile}
@@ -98,7 +99,7 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable
def error(msg: String) = reporter.error(null, msg)
def warning(msg: String) = reporter.warning(null, msg)
- def inform(msg: String) = System.err.println(msg)
+ def inform(msg: String) = Console.err.println(msg)
def inform[T](msg: String, value: T): T = { inform(msg+value); value }
//reporter.info(null, msg, true)
@@ -107,9 +108,9 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable
if (settings.verbose.value) inform("[" + msg + "]")
def informTime(msg: String, start: Long) =
- informProgress(msg + " in " + (System.currentTimeMillis() - start) + "ms")
+ informProgress(msg + " in " + (currentTime - start) + "ms")
- def log(msg: Object): unit =
+ def log(msg: AnyRef): unit =
if (settings.log contains phase.name) inform("[log " + phase + "] " + msg)
class ErrorWithPosition(val pos: Int, val error: Throwable) extends Error
@@ -460,14 +461,14 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable
else false
def compileSources(sources: List[SourceFile]): unit = {
- val startTime = System.currentTimeMillis()
+ val startTime = currentTime
reporter.reset
for (val source <- sources)
addUnit(new CompilationUnit(source))
globalPhase = firstPhase
while (globalPhase != terminalPhase && reporter.errors == 0) {
- val startTime = System.currentTimeMillis()
+ val startTime = currentTime
phase = globalPhase
globalPhase.run
if (settings.print contains globalPhase.name)
diff --git a/src/compiler/scala/tools/nsc/Interpreter.scala b/src/compiler/scala/tools/nsc/Interpreter.scala
index b61d6ae483..836512bae0 100644
--- a/src/compiler/scala/tools/nsc/Interpreter.scala
+++ b/src/compiler/scala/tools/nsc/Interpreter.scala
@@ -6,6 +6,7 @@
package scala.tools.nsc
+import java.lang.{Class, ClassLoader}
import java.io.{File, PrintWriter, StringWriter}
import java.net.URLClassLoader
@@ -353,7 +354,7 @@ class Interpreter(val settings: Settings, reporter: Reporter, out: PrintWriter)
.get)
var argsHolder: Array[Any] = null // XXX this roundabout approach is to try and make sure the value is boxed
argsHolder = List(value).toArray
- setterMethod.invoke(null, argsHolder.asInstanceOf[Array[Object]])
+ setterMethod.invoke(null, argsHolder.asInstanceOf[Array[AnyRef]])
interpret("val " + name + " = " + binderName + ".value")
}
diff --git a/src/compiler/scala/tools/nsc/InterpreterLoop.scala b/src/compiler/scala/tools/nsc/InterpreterLoop.scala
index bbd7112129..c3024d93f3 100644
--- a/src/compiler/scala/tools/nsc/InterpreterLoop.scala
+++ b/src/compiler/scala/tools/nsc/InterpreterLoop.scala
@@ -6,6 +6,8 @@
package scala.tools.nsc
+import java.lang.System
+import java.lang.ClassLoader
import java.io._
import scala.tools.nsc.reporters.{Reporter, ConsoleReporter}
diff --git a/src/compiler/scala/tools/nsc/Main.scala b/src/compiler/scala/tools/nsc/Main.scala
index 85db0730f0..712fb38704 100644
--- a/src/compiler/scala/tools/nsc/Main.scala
+++ b/src/compiler/scala/tools/nsc/Main.scala
@@ -5,6 +5,7 @@
// $Id$
package scala.tools.nsc
+import java.lang.System.getProperty
import scala.tools.nsc.util.FakePos //{Position}
import scala.tools.nsc.reporters.{Reporter, ConsoleReporter}
import scala.tools.nsc.doc.DocGenerator
@@ -13,14 +14,11 @@ import scala.tools.nsc.doc.DocGenerator
/** The main class for NSC, a compiler for the programming
* language Scala.
*/
-object Main extends Object with EvalLoop {
+object Main extends AnyRef with EvalLoop {
- val PRODUCT: String =
- System.getProperty("scala.tool.name", "scalac")
- val VERSION: String =
- System.getProperty("scala.tool.version", "unknown version")
- val COPYRIGHT: String =
- System.getProperty("scala.copyright", "(c) 2002-2006 LAMP/EPFL")
+ val PRODUCT: String = getProperty("scala.tool.name", "scalac")
+ val VERSION: String = getProperty("scala.tool.version", "unknown version")
+ val COPYRIGHT: String = getProperty("scala.copyright", "(c) 2002-2006 LAMP/EPFL")
val versionMsg = PRODUCT + " " + VERSION + " -- " + COPYRIGHT
val prompt = "\nnsc> "
@@ -96,7 +94,7 @@ object Main extends Object with EvalLoop {
def main(args: Array[String]): unit = {
process(args)
- System.exit(if (reporter.errors > 0) 1 else 0)
+ exit(if (reporter.errors > 0) 1 else 0)
}
}
diff --git a/src/compiler/scala/tools/nsc/MainGenericRunner.scala b/src/compiler/scala/tools/nsc/MainGenericRunner.scala
index fb7699b566..1a8a3e02b9 100644
--- a/src/compiler/scala/tools/nsc/MainGenericRunner.scala
+++ b/src/compiler/scala/tools/nsc/MainGenericRunner.scala
@@ -7,6 +7,8 @@
package scala.tools.nsc
+import java.lang.System.getProperty
+import java.lang.{ClassNotFoundException, NoSuchMethodException}
import java.io.File
import java.lang.reflect.InvocationTargetException
@@ -20,7 +22,7 @@ object MainGenericRunner {
* input classpath is empty; otherwise do not.
*/
def addClasspathExtras(classpath: String): String = {
- val scalaHome = System.getProperty("scala.home")
+ val scalaHome = getProperty("scala.home")
if (scalaHome == null)
return classpath
@@ -62,8 +64,7 @@ object MainGenericRunner {
}
if (settings.version.value) {
- val version =
- System.getProperty("scala.tool.version", "unknown version")
+ val version = getProperty("scala.tool.version", "unknown version")
Console.println(
"Scala code runner version " + version + " -- " +
"(c) 2002-2006 LAMP/EPFL")
diff --git a/src/compiler/scala/tools/nsc/MainTokenMetric.scala b/src/compiler/scala/tools/nsc/MainTokenMetric.scala
index 0fe6e0a2cc..8eaf3243f6 100644
--- a/src/compiler/scala/tools/nsc/MainTokenMetric.scala
+++ b/src/compiler/scala/tools/nsc/MainTokenMetric.scala
@@ -6,7 +6,7 @@
package scala.tools.nsc
-//import java.io._
+import compat.Math.log
import scala.tools.nsc.reporters.{Reporter, ConsoleReporter}
/** The main class for NSC, a compiler for the programming
@@ -28,7 +28,7 @@ object MainTokenMetric {
i = i + 1
s.nextToken()
}
- var j = 0 ; while(j + Math.log(i)/ Math.log(10) < 7) {
+ var j = 0 ; while(j + log(i) / log(10) < 7) {
j = j+1
Console.print(' ')
}
@@ -56,7 +56,7 @@ object MainTokenMetric {
def main(args: Array[String]): unit = {
process(args)
- System.exit(if (reporter.errors > 0) 1 else 0)
+ exit(if (reporter.errors > 0) 1 else 0)
}
}
diff --git a/src/compiler/scala/tools/nsc/ObjectRunner.scala b/src/compiler/scala/tools/nsc/ObjectRunner.scala
index b3cbc88dc9..7e3442ce02 100644
--- a/src/compiler/scala/tools/nsc/ObjectRunner.scala
+++ b/src/compiler/scala/tools/nsc/ObjectRunner.scala
@@ -7,6 +7,8 @@
package scala.tools.nsc
+import java.lang.Class
+import java.lang.{ClassNotFoundException, NoSuchMethodException}
import java.io.File
import java.lang.reflect.{Method,Modifier}
import java.net.URLClassLoader
diff --git a/src/compiler/scala/tools/nsc/ScriptRunner.scala b/src/compiler/scala/tools/nsc/ScriptRunner.scala
index 3d7ec1d214..c0b92195f3 100644
--- a/src/compiler/scala/tools/nsc/ScriptRunner.scala
+++ b/src/compiler/scala/tools/nsc/ScriptRunner.scala
@@ -11,6 +11,7 @@ import java.io.{BufferedReader, File, FileInputStream, FileOutputStream,
import java.util.jar.{JarEntry, JarOutputStream}
import java.lang.reflect.InvocationTargetException
+import compat.StringBuilder
import scala.tools.nsc.io.PlainFile
import scala.tools.nsc.reporters.ConsoleReporter
import scala.tools.nsc.util.{CompoundSourceFile, SourceFile, SourceFileFragment}
@@ -93,7 +94,7 @@ object ScriptRunner {
/** Read the entire contents of a file as a String. */
private def contentsOfFile(filename: String): String = {
- val strbuf = new StringBuffer
+ val strbuf = new StringBuilder
val reader = new FileReader(filename)
val cbuf = new Array[Char](1024)
while(true) {
@@ -199,7 +200,7 @@ object ScriptRunner {
var fromServer = in.readLine()
while (fromServer != null) {
- System.out.println(fromServer)
+ Console.println(fromServer)
if (CompileSocket.errorPattern.matcher(fromServer).matches)
compok = false
diff --git a/src/compiler/scala/tools/nsc/Settings.scala b/src/compiler/scala/tools/nsc/Settings.scala
index cef810c3a5..c67dfeb272 100644
--- a/src/compiler/scala/tools/nsc/Settings.scala
+++ b/src/compiler/scala/tools/nsc/Settings.scala
@@ -6,6 +6,7 @@
package scala.tools.nsc
+import java.lang.System
import java.io.File
class Settings(error: String => unit) {
diff --git a/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala b/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala
index 5ccc143479..cf3d9f8809 100644
--- a/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala
@@ -6,7 +6,8 @@
package scala.tools.nsc.ast
-import scala.concurrent._
+import compat.StringBuilder
+import scala.concurrent.Lock
import symtab.Flags._
import java.lang.Math
@@ -215,7 +216,7 @@ abstract class TreeBrowsers {
def update(v: AnyRef): Unit = {
val t: Tree = v.asInstanceOf[Tree]
- val str = new StringBuffer()
+ val str = new StringBuilder()
var buf = new StringWriter()
t match {
diff --git a/src/compiler/scala/tools/nsc/ast/TreePrinters.scala b/src/compiler/scala/tools/nsc/ast/TreePrinters.scala
index ad447d6196..e5bc54cfcf 100644
--- a/src/compiler/scala/tools/nsc/ast/TreePrinters.scala
+++ b/src/compiler/scala/tools/nsc/ast/TreePrinters.scala
@@ -6,6 +6,8 @@
package scala.tools.nsc.ast
+import compat.Platform.{EOL => LINE_SEPARATOR}
+import compat.StringBuilder
import java.io.{OutputStream, PrintWriter, Writer}
import symtab.Flags._
@@ -19,8 +21,6 @@ abstract class TreePrinters {
protected val indentStep = 2
protected var indentString = " " // 40
- val LINE_SEPARATOR = System.getProperty("line.separator", "\n")
-
def flush = out.flush()
def indent = indentMargin = indentMargin + indentStep
@@ -106,7 +106,7 @@ abstract class TreePrinters {
def printAttributes(tree: Tree): unit = {
def attrInfoToString(attr: AttrInfo): String = {
- val str = new StringBuffer()
+ val str = new StringBuilder()
attr match {
case Triple(tp, args, nvPairs) =>
str.append(tp.toString())
diff --git a/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala b/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala
index 0adf872a81..3db2bd7673 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala
@@ -6,6 +6,7 @@
package scala.tools.nsc.ast.parser
+import compat.StringBuilder
import scala.collection.immutable.ListMap
import scala.collection.mutable
import scala.tools.nsc.util.Position
@@ -44,7 +45,7 @@ class MarkupParser(unit: CompilationUnit, s: Scanner, p: Parser, presWS: boolean
/*[Duplicate]*/ var ch: Char = _
/** character buffer, for names */
- /*[Duplicate]*/ protected val cbuf = new StringBuffer()
+ /*[Duplicate]*/ protected val cbuf = new StringBuilder()
/** append Unicode character to name buffer*/
/*[Duplicate]*/ protected def putChar(c: char) = cbuf.append(c)
@@ -174,7 +175,7 @@ class MarkupParser(unit: CompilationUnit, s: Scanner, p: Parser, presWS: boolean
xToken('A')
xToken('[')
val pos1 = pos
- val sb: StringBuffer = new StringBuffer()
+ val sb: StringBuilder = new StringBuilder()
while (true) {
if (ch==']' &&
{ sb.append(ch); nextch; ch == ']' } &&
@@ -190,7 +191,7 @@ class MarkupParser(unit: CompilationUnit, s: Scanner, p: Parser, presWS: boolean
def xUnparsed: Tree = {
val pos1 = pos
- val sb: StringBuffer = new StringBuffer()
+ val sb: StringBuilder = new StringBuilder()
while (true) {
if (ch=='<' &&
{ sb.append(ch); nextch; ch == '/' } &&
@@ -228,14 +229,14 @@ class MarkupParser(unit: CompilationUnit, s: Scanner, p: Parser, presWS: boolean
while (ch != ';') {
ch match {
case '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' =>
- i = i * base + Character.digit(ch, base)
+ i = i * base + ch.asDigit
case 'a' | 'b' | 'c' | 'd' | 'e' | 'f'
| 'A' | 'B' | 'C' | 'D' | 'E' | 'F' =>
if (!hex)
reportSyntaxError("hex char not allowed in decimal char ref\n"
+"Did you mean to write &#x ?");
else
- i = i * base + Character.digit(ch, base)
+ i = i * base + ch.asDigit
case _ =>
reportSyntaxError("character '"+ch+" not allowed in char ref\n")
}
@@ -249,7 +250,7 @@ class MarkupParser(unit: CompilationUnit, s: Scanner, p: Parser, presWS: boolean
* see [15]
*/
/*[Duplicate]*/ def xComment: Tree = {
- val sb: StringBuffer = new StringBuffer()
+ val sb: StringBuilder = new StringBuilder()
xToken('-')
xToken('-')
while (true) {
@@ -306,7 +307,7 @@ class MarkupParser(unit: CompilationUnit, s: Scanner, p: Parser, presWS: boolean
ts.append(xEmbeddedExpr)
else {
appendText(p, ts, xText)/*
- val str = new StringBuffer("{")
+ val str = new StringBuilder("{")
str.append(xText)
nextch
appendText(p, ts, str.toString())*/
@@ -430,7 +431,7 @@ class MarkupParser(unit: CompilationUnit, s: Scanner, p: Parser, presWS: boolean
* see [15]
*/
/*[Duplicate]*/ def xProcInstr: Tree = {
- val sb:StringBuffer = new StringBuffer();
+ val sb:StringBuilder = new StringBuilder();
val n = xName;
if( xml.Parsing.isSpace( ch ) ) {
xSpace;
@@ -478,7 +479,7 @@ class MarkupParser(unit: CompilationUnit, s: Scanner, p: Parser, presWS: boolean
//}
}
- //val cbuf = new StringBuffer();
+ //val cbuf = new StringBuilder();
/** append Unicode character to name buffer*/
//private def putChar(c: char) = cbuf.append( c );
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
index 9fc9b574a5..35f4c7b404 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
@@ -6,6 +6,7 @@
package scala.tools.nsc.ast.parser
+import compat.StringBuilder
import Tokens._
import scala.tools.nsc.util.{Position, SourceFile}
import SourceFile.{LF, FF, CR, SU}
@@ -61,7 +62,7 @@ trait Scanners requires SyntaxAnalyzer {
/** character buffer for literals
*/
- val cbuf = new StringBuffer()
+ val cbuf = new StringBuilder()
/** append Unicode character to "lit" buffer
*/
@@ -75,7 +76,7 @@ trait Scanners requires SyntaxAnalyzer {
/** buffer for the documentation comment
*/
- var docBuffer: StringBuffer = null
+ var docBuffer: StringBuilder = null
/** add the given character to the documentation buffer
*/
@@ -416,7 +417,7 @@ trait Scanners requires SyntaxAnalyzer {
var openComments = 1
in.next
if (in.ch == '*' && onlyPresentation)
- docBuffer = new StringBuffer("/**")
+ docBuffer = new StringBuilder("/**")
while (openComments > 0) {
do {
do {
@@ -819,7 +820,7 @@ trait Scanners requires SyntaxAnalyzer {
def enterKeyword(n: Name, tokenId: int): unit = {
while (tokenId >= tokenName.length) {
val newTokName = new Array[Name](tokenName.length * 2)
- System.arraycopy(tokenName, 0, newTokName, 0, newTokName.length)
+ Array.copy(tokenName, 0, newTokName, 0, newTokName.length)
tokenName = newTokName
}
tokenName(tokenId) = n
diff --git a/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala b/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala
index 1363d4fecb..b3bdcce65f 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/BasicBlocks.scala
@@ -7,6 +7,7 @@
package scala.tools.nsc.backend.icode;
+import compat.StringBuilder;
import scala.tools.nsc.ast._;
import scala.collection.mutable.Map;
import scala.tools.nsc.util.Position;
@@ -163,14 +164,14 @@ trait BasicBlocks requires ICodes {
if (i < instrs.length) {
val newInstrs = new Array[Instruction](instrs.length + is.length - 1);
changed = true;
- System.arraycopy(instrs, 0, newInstrs, 0, i);
+ Array.copy(instrs, 0, newInstrs, 0, i);
var j = i;
for (val x <- is) {
newInstrs(j) = x;
j = j + 1;
}
if (i + 1 < instrs.length)
- System.arraycopy(instrs, i + 1, newInstrs, j, instrs.length - i - 1)
+ Array.copy(instrs, i + 1, newInstrs, j, instrs.length - i - 1)
instrs = newInstrs;
}
@@ -335,7 +336,7 @@ trait BasicBlocks requires ICodes {
);
// Instead of it, rather use a printer
- def print() : unit = print(System.out);
+ def print() : unit = print(java.lang.System.out);
def print(out: java.io.PrintStream) : unit = {
out.println("block #"+label+" :");
@@ -347,7 +348,7 @@ trait BasicBlocks requires ICodes {
}
def fullString: String = {
- val buf = new StringBuffer();
+ val buf = new StringBuilder();
buf.append("Block ").append(label.toString());
buf.append("\nSuccessors: ").append(successors);
buf.append("\nPredecessors: ").append(predecessors);
diff --git a/src/compiler/scala/tools/nsc/backend/icode/Checkers.scala b/src/compiler/scala/tools/nsc/backend/icode/Checkers.scala
index c9ecf46c52..a6a3f2c2d8 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/Checkers.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/Checkers.scala
@@ -546,7 +546,7 @@ abstract class Checkers {
//////////////// Error reporting /////////////////////////
def error(msg: String): Unit = {
- System.out.println(method.toString() + " in block: " + basicBlock.label)
+ Console.println(method.toString() + " in block: " + basicBlock.label)
printLastIntructions
Checkers.this.global.error("ICode checker: " + method + ": " + msg)
@@ -562,7 +562,7 @@ abstract class Checkers {
buf = i :: buf
printed = printed + 1
});
- buf foreach System.out.println
+ buf foreach Console.println
Console.println("at: " + clasz.cunit.position(buf.head.pos))
}
diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
index 9a6d31895b..9c20e63d3c 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
@@ -7,6 +7,7 @@
package scala.tools.nsc.backend.icode
+import compat.StringBuilder
import scala.collection.mutable.{Map, HashMap}
import scala.tools.nsc.symtab._
@@ -1547,7 +1548,7 @@ abstract class GenICode extends SubComponent {
var handlerCount = 0
override def toString(): String = {
- val buf = new StringBuffer()
+ val buf = new StringBuilder()
buf.append("\tpackage: ").append(packg).append('\n')
buf.append("\tclazz: ").append(clazz).append('\n')
buf.append("\tmethod: ").append(method).append('\n')
diff --git a/src/compiler/scala/tools/nsc/backend/icode/ICodes.scala b/src/compiler/scala/tools/nsc/backend/icode/ICodes.scala
index 6977f82e4e..4806c575b3 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/ICodes.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/ICodes.scala
@@ -46,14 +46,14 @@ abstract class ICodes extends AnyRef
/** Print all classes and basic blocks. Used for debugging. */
def dump: Unit = {
- val printer = new global.icodePrinter.TextPrinter(new PrintWriter(System.out, true),
+ val printer = new global.icodePrinter.TextPrinter(new PrintWriter(Console.out, true),
new global.icodes.DumpLinearizer());
global.icodes.classes.values foreach { c => printer.printClass(c); }
}
def dump(m: global.icodes.IMethod) = {
- val printer = new global.icodePrinter.TextPrinter(new PrintWriter(System.out, true),
+ val printer = new global.icodePrinter.TextPrinter(new PrintWriter(Console.out, true),
new global.icodes.DumpLinearizer());
printer.printMethod(m);
}
diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala
index dfaf52a24c..a2b3d94736 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala
@@ -1,5 +1,6 @@
package scala.tools.nsc.backend.icode.analysis;
+import compat.StringBuilder
import scala.collection.mutable.{HashMap, Map}
import scala.collection.immutable.{Set, ListSet}
@@ -99,7 +100,7 @@ abstract class Liveness {
} /* def interpret */
override def toString(): String = {
- val buf = new StringBuffer();
+ val buf = new StringBuilder();
for (val b <- method.code.blocks.toList) {
buf.append("\nlive-in(" + b + ")=" + in(b) + "\nlive-out(" + b + ")=" + out(b));
}
diff --git a/src/compiler/scala/tools/nsc/doc/DocGenerator.scala b/src/compiler/scala/tools/nsc/doc/DocGenerator.scala
index 3c06d98bad..db2f6eb64d 100644
--- a/src/compiler/scala/tools/nsc/doc/DocGenerator.scala
+++ b/src/compiler/scala/tools/nsc/doc/DocGenerator.scala
@@ -10,6 +10,7 @@ import java.io.{File, FileOutputStream, FileWriter}
import java.util.StringTokenizer
import java.util.regex.Pattern
+import compat.Platform.{EOL => LINE_SEPARATOR}
import scala.collection.immutable._
import scala.collection.mutable.ListBuffer
import scala.tools.nsc._
@@ -938,8 +939,6 @@ abstract class DocGenerator extends Models {
val root = <b></b>
- private val LINE_SEPARATOR = System.getProperty("line.separator", "\n")
-
private val NAME_SUFFIX_OBJECT = "$object"
private val NAME_SUFFIX_PACKAGE = "$package"
private val FILE_EXTENSION_HTML = ".html"
diff --git a/src/compiler/scala/tools/nsc/io/AbstractFile.scala b/src/compiler/scala/tools/nsc/io/AbstractFile.scala
index 5d2321c96e..9fe5ccfbd7 100644
--- a/src/compiler/scala/tools/nsc/io/AbstractFile.scala
+++ b/src/compiler/scala/tools/nsc/io/AbstractFile.scala
@@ -70,7 +70,7 @@ object AbstractFile {
* <code>global.settings.encoding.value</code>.
* </p>
*/
-abstract class AbstractFile extends Object with Iterable[AbstractFile] {
+abstract class AbstractFile extends AnyRef with Iterable[AbstractFile] {
//########################################################################
// Public Methods
diff --git a/src/compiler/scala/tools/nsc/io/VirtualFile.scala b/src/compiler/scala/tools/nsc/io/VirtualFile.scala
index 1f3d62c241..63e8674125 100644
--- a/src/compiler/scala/tools/nsc/io/VirtualFile.scala
+++ b/src/compiler/scala/tools/nsc/io/VirtualFile.scala
@@ -7,6 +7,7 @@
package scala.tools.nsc.io
+import compat.Math.MIN_LONG
import java.io.{File,InputStream}
/** This class implements an empty abstract regular file.
@@ -43,7 +44,7 @@ class VirtualFile(val name: String, _path: String) extends AbstractFile {
def isDirectory: Boolean = false
/** Returns the time that this abstract file was last modified. */
- def lastModified: Long = Long.MIN_VALUE
+ def lastModified: Long = MIN_LONG
/** Returns all abstract subfiles of this abstract directory. */
def elements: Iterator[AbstractFile] = {
diff --git a/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala b/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala
index c123ba96a1..1fb184d9a4 100644
--- a/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala
+++ b/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala
@@ -6,6 +6,7 @@
package scala.tools.nsc.matching
+import compat.StringBuilder
import scala.tools.nsc.util.Position
/** This trait ...
@@ -292,7 +293,7 @@ trait PatternMatchers requires (transform.ExplicitOuter with PatternNodes) {
/** pretty printer
*/
def print(): Unit =
- Console.println(root.and.print("", new StringBuffer()).toString())
+ Console.println(root.and.print("", new StringBuilder()).toString())
/** enters a sequence of cases into the pattern matcher
*/
@@ -323,9 +324,9 @@ trait PatternMatchers requires (transform.ExplicitOuter with PatternNodes) {
val bd = new Array[Array[ValDef]](tree.bound.length + 1)
val ng = new Array[Tree](tree.guard.length + 1)
val nb = new Array[Tree](tree.body.length + 1)
- System.arraycopy(tree.bound, 0, bd, 0, tree.bound.length)
- System.arraycopy(tree.guard, 0, ng, 0, tree.guard.length)
- System.arraycopy(tree.body, 0, nb, 0, tree.body.length)
+ Array.copy(tree.bound, 0, bd, 0, tree.bound.length)
+ Array.copy(tree.guard, 0, ng, 0, tree.guard.length)
+ Array.copy(tree.body, 0, nb, 0, tree.body.length)
bd(bd.length - 1) = bound
ng(ng.length - 1) = guard
nb(nb.length - 1) = body
@@ -577,7 +578,7 @@ print()
}
val caseAccs = casted.tpe.symbol.caseFieldAccessors;
- if (caseAccs.length <= index) System.out.println("selecting " + index + " in case fields of " + casted.tpe.symbol + "=" + casted.tpe.symbol.caseFieldAccessors);//debug
+ if (caseAccs.length <= index) Console.println("selecting " + index + " in case fields of " + casted.tpe.symbol + "=" + casted.tpe.symbol.caseFieldAccessors);//debug
val ts = caseAccs(index);
val accTree = typed(Apply(Select(ident, ts), List()))
val accType = accTree.tpe
diff --git a/src/compiler/scala/tools/nsc/matching/PatternNodes.scala b/src/compiler/scala/tools/nsc/matching/PatternNodes.scala
index ee1ff7f674..eda7336711 100644
--- a/src/compiler/scala/tools/nsc/matching/PatternNodes.scala
+++ b/src/compiler/scala/tools/nsc/matching/PatternNodes.scala
@@ -6,6 +6,7 @@
package scala.tools.nsc.matching
+import compat.StringBuilder
import scala.tools.nsc.util.Position
trait PatternNodes requires transform.ExplicitOuter {
@@ -171,14 +172,14 @@ trait PatternNodes requires transform.ExplicitOuter {
"<unknown pat>"
}
- def print(indent: String, sb: StringBuffer): StringBuffer = {
+ def print(indent: String, sb: StringBuilder): StringBuilder = {
val patNode = this
def cont = if (patNode.or != null) patNode.or.print(indent, sb) else sb
def newIndent(s: String) = {
val removeBar: Boolean = (null == patNode.or)
- val sb = new StringBuffer()
+ val sb = new StringBuilder()
sb.append(indent)
if (removeBar)
sb.setCharAt(indent.length() - 1, ' ')
@@ -316,7 +317,7 @@ trait PatternNodes requires transform.ExplicitOuter {
//@maybe is corrected now? bq
if (numVars == boundVars.length) {
val newVars = new Array[ValDef](numVars * 2)
- System.arraycopy(boundVars, 0, newVars, 0, numVars)
+ Array.copy(boundVars, 0, newVars, 0, numVars)
this.boundVars = newVars
}
sym.setInfo(tpe)
@@ -326,7 +327,7 @@ trait PatternNodes requires transform.ExplicitOuter {
def getBoundVars(): Array[ValDef] = {
val newVars = new Array[ValDef](numVars)
- System.arraycopy(boundVars, 0, newVars, 0, numVars)
+ Array.copy(boundVars, 0, newVars, 0, numVars)
newVars
}
diff --git a/src/compiler/scala/tools/nsc/models/Models.scala b/src/compiler/scala/tools/nsc/models/Models.scala
index ac5782abdd..07286a0153 100644
--- a/src/compiler/scala/tools/nsc/models/Models.scala
+++ b/src/compiler/scala/tools/nsc/models/Models.scala
@@ -86,7 +86,7 @@ abstract class Models {
else if (term0.isTypeParameter) TPARAM
else if (term0.isType) TPARAM
else {
- // System.err.println("UNRECOGNIZED SYMBOL: " + term0 + " " + name);
+ // Console.err.println("UNRECOGNIZED SYMBOL: " + term0 + " " + name);
null
}
} else {
@@ -200,20 +200,20 @@ abstract class Models {
def member(tree: Tree, members: List[Tree]): Tree = tree
def update0(members1: List[Tree]): Boolean = {
- // System.err.println("update0 " + this + " " + members1)
+ // Console.err.println("update0 " + this + " " + members1)
if (members1.length == 1 && members1.head.isInstanceOf[PackageDef])
return update0(members1.head.asInstanceOf[PackageDef].stats)
val marked = new HashSet[HasTree]
var updated = false
for (val mmbr1 <- members1) if (mmbr1.isInstanceOf[PackageDef]) {
- System.err.println("PACKAGE: " + mmbr1.symbol + " " + members1.length)
+ Console.err.println("PACKAGE: " + mmbr1.symbol + " " + members1.length)
} else if (isMember(mmbr1)) {
val mmbr2 = member(mmbr1, members1)
if (mmbr2 != null) {
var found = false
for (val mmbr <- members) if (!found && mmbr.replacedBy(mmbr2)) {
- //System.err.println("REPLACE: " + mmbr + " with " + mmbr2)
+ //Console.err.println("REPLACE: " + mmbr + " with " + mmbr2)
mmbr.mods0 = mods1(mmbr1)
found = true
updated = mmbr.update(mmbr2) || updated
@@ -231,7 +231,7 @@ abstract class Models {
marked += add
}
}
- // System.err.println("update1 " + this + " " + members + " " + marked)
+ // Console.err.println("update1 " + this + " " + members + " " + marked)
}
val sz = members.size
members.intersect(marked)
diff --git a/src/compiler/scala/tools/nsc/models/SemanticTokens.scala b/src/compiler/scala/tools/nsc/models/SemanticTokens.scala
index e191fc171d..6404a4fa28 100644
--- a/src/compiler/scala/tools/nsc/models/SemanticTokens.scala
+++ b/src/compiler/scala/tools/nsc/models/SemanticTokens.scala
@@ -6,6 +6,8 @@
package scala.tools.nsc.models
+import java.lang.Thread
+import java.lang.Character.isJavaIdentifierPart
import scala.collection.mutable.{HashMap,HashSet}
import scala.tools.nsc.Global
import scala.tools.nsc.symtab.{Flags,Names}
@@ -173,7 +175,7 @@ class SemanticTokens(val compiler: Global) {
else if (term0.isTypeParameter) TPARAM
else if (term0.isType ) TPARAM
else {
- // System.err.println("UNRECOGNIZED SYMBOL: " + term0 + " " + name);
+ // Console.err.println("UNRECOGNIZED SYMBOL: " + term0 + " " + name);
null
}
}
@@ -203,7 +205,7 @@ class SemanticTokens(val compiler: Global) {
val pos = eatKeywords(unit.source, tree.pos)
if (pos == NoPos) {
// inner types.
- // System.err.println("NOPOS: " + tree.getClass() + " " + (new Position(unit.source, tree.pos)).dbgString);
+ // Console.err.println("NOPOS: " + tree.getClass() + " " + (new Position(unit.source, tree.pos)).dbgString);
//Thread.dumpStack();
} else buildDef(tree.symbol, eatKeywords(unit.source, tree.pos));
tree match {
@@ -221,7 +223,7 @@ class SemanticTokens(val compiler: Global) {
{
val pos : Int = if (tree.name.toString().equals("<init>")) NoPos else
eatKeywords(unit.source, tree.pos);
- if (false) System.err.println("VALDEF: tree=" + tree + " sym=" + tree.symbol + " pos0=" +
+ if (false) Console.err.println("VALDEF: tree=" + tree + " sym=" + tree.symbol + " pos0=" +
tree.symbol.pos + " alias=" + tree.symbol.alias + " pos1=" +
pos + " pos2=" + tree.pos + " " + unit.source.dbg(tree.pos) + " " + tree.symbol.hasFlag(Flags.SYNTHETIC));
@@ -243,21 +245,21 @@ class SemanticTokens(val compiler: Global) {
try {
//TPT=scala.Iterator[DocGenerator.this.compiler0.CompilationUnit] 260 class scala.tools.nsc.ast.Trees$TypeTree scala.Iterator[DocGenerator.this.compiler0.CompilationUnit] class scala.tools.nsc.symtab.Types$$anon$5
if (tree.tpt == null || tree.tpt.tpe == null) {
- //System.err.println("BAD: " + tree.tpt + " in " + tree);
+ //Console.err.println("BAD: " + tree.tpt + " in " + tree);
} else {
- //System.err.println("TPT=" + tree.tpt + " " + tree.tpt.pos + " " + tree.tpt.getClass() + " " + tree.tpt.tpe + " " + tree.tpt.tpe.getClass() + " " + tree.tpt.tpe.getClass().getSuperclass());
+ //Console.err.println("TPT=" + tree.tpt + " " + tree.tpt.pos + " " + tree.tpt.getClass() + " " + tree.tpt.tpe + " " + tree.tpt.tpe.getClass() + " " + tree.tpt.tpe.getClass().getSuperclass());
build(tree.tpt);
}
} catch {
case e: Error =>
- System.err.println("VALDEF: " + tree + " " + tree.tpt + " " + tree.pos + " " + tree.tpt.pos);
+ Console.err.println("VALDEF: " + tree + " " + tree.tpt + " " + tree.pos + " " + tree.tpt.pos);
throw e;
}
- //System.err.println("RHS: " + tree.rhs + " " + tree.rhs.getClass() + " " + tree.rhs.getClass().getSuperclass());
+ //Console.err.println("RHS: " + tree.rhs + " " + tree.rhs.getClass() + " " + tree.rhs.getClass().getSuperclass());
build(tree.rhs);
}
case tree: PackageDef =>
- //System.err.println("PACKAGE: " + tree.name);
+ //Console.err.println("PACKAGE: " + tree.name);
if (false) {
val pos = eatKeywords(unit.source, tree.pos)
if (pos != NoPos)
@@ -272,7 +274,7 @@ class SemanticTokens(val compiler: Global) {
unit.source.skipWhitespace(arg.pos + ("val ").length())
else if (unit.source.content(arg.pos) == ':') {
var posx : Int = arg.pos
- while (Character.isWhitespace(unit.source.content(posx - 1))) posx = posx - 1
+ while (unit.source.content(posx - 1).isWhitespace) posx = posx - 1
posx - name.length()
} else arg.pos
buildDef(arg.symbol, pos)
@@ -286,99 +288,99 @@ class SemanticTokens(val compiler: Global) {
if (clazz == null) Nil
else clazz :: classes(clazz.getSuperclass())
if (tree.original == null) {
- if (false) System.err.println("NO_ORIGINAL: " + tree + " " + tree.tpe + " " + classes(tree.tpe.getClass()));
+ if (false) Console.err.println("NO_ORIGINAL: " + tree + " " + tree.tpe + " " + classes(tree.tpe.getClass()));
}
if (tree.tpe != null) buildT(tree1, tree.tpe);
def buildT( tree : Tree, tpe : Type) : Unit = if (tree.pos != NoPos) tpe match {
case tpe0 : TypeRef => tree match {
case apt : AppliedTypeTree =>
buildUse(tpe.symbol, apt.tpt.pos, tpe0);
- //System.err.println("APT: " + treex + " vs. " + treex.original);
- //System.err.println("APT: " + treex.pos + " vs. " + treex.original.pos + " " + unit.source.dbg(treex.original.pos));
- //System.err.println("APT: " + apt.tpt + " sym0=" + apt.tpt.symbol + " sym1=" + tpe0.sym + " apt.args=" + apt.args + " tpe0.args=" + tpe0.args);
+ //Console.err.println("APT: " + treex + " vs. " + treex.original);
+ //Console.err.println("APT: " + treex.pos + " vs. " + treex.original.pos + " " + unit.source.dbg(treex.original.pos));
+ //Console.err.println("APT: " + apt.tpt + " sym0=" + apt.tpt.symbol + " sym1=" + tpe0.sym + " apt.args=" + apt.args + " tpe0.args=" + tpe0.args);
buildTs (apt.args, tpe0.args);
case ident : Ident => buildUse(tpe0.sym, ident.pos, tpe0);
case select : Select =>
if (select.symbol == NoSymbol)
- if (false) System.err.println("BUILD_SELECT: " + select + " @ " + tpe0 + " SYM=" + select.symbol + " " + unit.source.dbg(select.pos));
+ if (false) Console.err.println("BUILD_SELECT: " + select + " @ " + tpe0 + " SYM=" + select.symbol + " " + unit.source.dbg(select.pos));
try {
// build(select);
buildUse(tpe0.symbol, selectPos(select), tpe0);
- //System.err.println("QUALIFIER: " + select.qualifier + " " + unit.source.dbg(select.qualifier.pos) + " " + tpe0.prefix + " " + tpe0.prefix.getClass() + " " + tpe0.prefix.getClass().getSuperclass() +" " + tpe0.prefix.widen + " " + tpe0.prefix.toLongString);
+ //Console.err.println("QUALIFIER: " + select.qualifier + " " + unit.source.dbg(select.qualifier.pos) + " " + tpe0.prefix + " " + tpe0.prefix.getClass() + " " + tpe0.prefix.getClass().getSuperclass() +" " + tpe0.prefix.widen + " " + tpe0.prefix.toLongString);
buildT(select.qualifier, tpe0.prefix);
} catch {
case e : Error =>
- System.err.println("BUILD_SELECT: " + select + " @ " + tpe0 + " " + unit.source.dbg(select.pos));
+ Console.err.println("BUILD_SELECT: " + select + " @ " + tpe0 + " " + unit.source.dbg(select.pos));
throw e;
}
case tpt : TypeTree =>
if (tpt.symbol != null) {
- System.err.println("SYM0 " + tpt.symbol + " " + unit.source.dbg(tpt.pos));
+ Console.err.println("SYM0 " + tpt.symbol + " " + unit.source.dbg(tpt.pos));
buildUse(tpt.symbol, tpt.pos, tpe0);
} else if (tpe0.symbol != null) {
- //System.err.println("TYPE_SYM1 " + tpe0.symbol + " " + unit.source.dbg(tpt.pos));
+ //Console.err.println("TYPE_SYM1 " + tpe0.symbol + " " + unit.source.dbg(tpt.pos));
buildUse(tpe0.symbol, tpt.pos, tpe0);
} else {
- System.err.println("UNKNOWN TPT0: " + unit.source.dbg(tpt.pos) + " tpt=" + tpt + " " + tpt.symbol + " tpe0="+ tpe0 + " " + tpe0.symbol + " tpe0.args=" + tpe0.args);
+ Console.err.println("UNKNOWN TPT0: " + unit.source.dbg(tpt.pos) + " tpt=" + tpt + " " + tpt.symbol + " tpe0="+ tpe0 + " " + tpe0.symbol + " tpe0.args=" + tpe0.args);
}
case sft : SelectFromTypeTree =>
build(sft.qualifier); // XXX: broken
- if (false) System.err.println("SFTT: " + sft + " sym=" + sft.symbol + " selector=" + sft.selector + " qual=" + sft.qualifier + " qual.sym=" +
+ if (false) Console.err.println("SFTT: " + sft + " sym=" + sft.symbol + " selector=" + sft.selector + " qual=" + sft.qualifier + " qual.sym=" +
sft.qualifier.symbol +
" qual.pos=" + unit.source.dbg(sft.qualifier.pos) + " symbol=" + sft.symbol + " type=" + tpe0 +
" type.sym=" + tpe0.symbol);
- case _ => System.err.println("UNKNOWN TPT2: " + tree + " vs. " + tpe0 + " " + tree.getClass() + " " + unit.source.content(tree.pos));
+ case _ => Console.err.println("UNKNOWN TPT2: " + tree + " vs. " + tpe0 + " " + tree.getClass() + " " + unit.source.content(tree.pos));
}
case tpe0 : MethodType => tree match {
case tpt: TypeTree =>
if (tpt.original != null) buildT(tpt.original, tpe);
else {
- System.err.println("UNKNOWN TPT3: " + tree + " vs. " + tpe0 + " " + unit.source.content(tree.pos));
+ Console.err.println("UNKNOWN TPT3: " + tree + " vs. " + tpe0 + " " + unit.source.content(tree.pos));
}
case ident : Ident => buildT(ident, tpe0.resultType);
case select : Select => buildT(select, tpe0.resultType);
- case _ => System.err.println("UNKNOWN TPE: " + tree + " vs. " + tpe0 + " " + tree.getClass());
+ case _ => Console.err.println("UNKNOWN TPE: " + tree + " vs. " + tpe0 + " " + tree.getClass());
}
case tpe0 : RefinedType => tree match {
case cpt : CompoundTypeTree =>
buildTs(cpt.templ.parents, tpe0.parents);
case _ : TypeTree =>
- // System.err.println("UNKNOWN TPE13: " + dbg(tree) + " tpe0=" + tpe0 + " " + tpe0.parents);
+ // Console.err.println("UNKNOWN TPE13: " + dbg(tree) + " tpe0=" + tpe0 + " " + tpe0.parents);
case _ =>
- if (false) System.err.println("UNKNOWN TPE5: " + dbg(tree) + " tpe0=" + tpe0 + " " + tpe0.parents);
+ if (false) Console.err.println("UNKNOWN TPE5: " + dbg(tree) + " tpe0=" + tpe0 + " " + tpe0.parents);
}
case tpe0 : ThisType => tree match {
case stt : SingletonTypeTree => stt.ref match {
case ths : This => build(ths);
- case _ => System.err.println("UNKNOWN TPE11: " + tpe0 + " " + stt + " " + stt.ref + " " + stt.ref.getClass() + " " + unit.source.dbg(tree.pos));
+ case _ => Console.err.println("UNKNOWN TPE11: " + tpe0 + " " + stt + " " + stt.ref + " " + stt.ref.getClass() + " " + unit.source.dbg(tree.pos));
}
case tt : This =>
case _ : Ident =>
case _ : Select =>
case tt : TypeTree =>
- if (false) System.err.println("UNKNOWN TPE12: " + tpe0 + " " + tree + " " + tree.getClass() + " " + unit.source.dbg(tree.pos));
+ if (false) Console.err.println("UNKNOWN TPE12: " + tpe0 + " " + tree + " " + tree.getClass() + " " + unit.source.dbg(tree.pos));
case _ =>
- if (false) System.err.println("UNKNOWN TPE10: " + tpe0 + " " + tree + " " + tree.getClass() + " " + unit.source.dbg(tree.pos));
+ if (false) Console.err.println("UNKNOWN TPE10: " + tpe0 + " " + tree + " " + tree.getClass() + " " + unit.source.dbg(tree.pos));
}
case tpe0 : SingleType => tree match {
case ident : Ident => buildUse(tpe0.sym, ident.pos, tpe0);
case select : Select =>
buildUse(tpe0.symbol, selectPos(select), tpe0);
- //System.err.println("QUALIFIER-0: " + select.qualifier + " " + unit.source.dbg(select.qualifier.pos) + " " + tpe0.prefix + " " + tpe0.prefix.getClass() + " " + tpe0.prefix.getClass().getSuperclass() +" " + tpe0.prefix.widen + " " + tpe0.prefix.toLongString);
+ //Console.err.println("QUALIFIER-0: " + select.qualifier + " " + unit.source.dbg(select.qualifier.pos) + " " + tpe0.prefix + " " + tpe0.prefix.getClass() + " " + tpe0.prefix.getClass().getSuperclass() +" " + tpe0.prefix.widen + " " + tpe0.prefix.toLongString);
buildT(select.qualifier, tpe0.prefix);
case _ =>
- if (false) System.err.println("UNKNOWN TPE8: " + tree + " " + unit.source.dbg(tree.pos) + " TPE=" + tpe0 + " PRE=" + tpe0.pre + " SYM=" + tpe0.sym);
+ if (false) Console.err.println("UNKNOWN TPE8: " + tree + " " + unit.source.dbg(tree.pos) + " TPE=" + tpe0 + " PRE=" + tpe0.pre + " SYM=" + tpe0.sym);
}
case ctype : ConstantType =>
- if (false) System.err.println("UNKNOWN CONSTANT_TYPE: " + tree + " " + ctype + " " + unit.source.dbg(tree.pos));
+ if (false) Console.err.println("UNKNOWN CONSTANT_TYPE: " + tree + " " + ctype + " " + unit.source.dbg(tree.pos));
case ErrorType =>
case _ => {
- if (false) System.err.println("UNKNOWN TPE4: " + tree + " " + tpe + " " + tpe.getClass() + " " + unit.source.dbg(tree.pos));
+ if (false) Console.err.println("UNKNOWN TPE4: " + tree + " " + tpe + " " + tpe.getClass() + " " + unit.source.dbg(tree.pos));
}
};
def buildTs(trees : List[Tree], types : List[Type]): Unit = if (!trees.isEmpty && !types.isEmpty) {
@@ -395,7 +397,7 @@ class SemanticTokens(val compiler: Global) {
};
case tree: AbsTypeDef =>
- //System.err.println("ABS: " + tree.symbol + " " + unit.source.dbg(tree.namePos) + " " + unit.source.dbg(tree.pos));
+ //Console.err.println("ABS: " + tree.symbol + " " + unit.source.dbg(tree.namePos) + " " + unit.source.dbg(tree.pos));
buildDef(tree.symbol, tree.namePos)
buildDef(tree.symbol, tree.pos)
build(tree.lo)
@@ -409,32 +411,32 @@ class SemanticTokens(val compiler: Global) {
try {
build(tree.qualifier)
} catch {
- case e : Error => System.err.println("SELECTQ: " + tree + " " + tree.qualifier + " " + unit.source.dbg(tree.qualifier.pos)); throw e;
+ case e : Error => Console.err.println("SELECTQ: " + tree + " " + tree.qualifier + " " + unit.source.dbg(tree.qualifier.pos)); throw e;
}
try {
if (tree.pos >= unit.source.content.length) {
- if (false) System.err.println("BAD_SELECT_QUALIFIER " + tree + " @ " + unit.source.dbg(tree.pos));
+ if (false) Console.err.println("BAD_SELECT_QUALIFIER " + tree + " @ " + unit.source.dbg(tree.pos));
} else {
- //System.err.println("SELECT-0: " + tree.symbol + " " + unit.source.dbg(tree.pos) + " " + (tree.pos - selectPos(tree)));
+ //Console.err.println("SELECT-0: " + tree.symbol + " " + unit.source.dbg(tree.pos) + " " + (tree.pos - selectPos(tree)));
buildUse(tree.symbol, selectPos(tree), tree.tpe);
}
} catch {
- case e : Error => System.err.println("SELECTU: " + tree + " " + tree.symbol + " " + unit.source.dbg(tree.pos)); throw e;
+ case e : Error => Console.err.println("SELECTU: " + tree + " " + tree.symbol + " " + unit.source.dbg(tree.pos)); throw e;
}
case tree: TypeApply =>
- //System.err.println("TYPE_APPLY: " + tree + " " + unit.source.dbg(tree.pos));
+ //Console.err.println("TYPE_APPLY: " + tree + " " + unit.source.dbg(tree.pos));
if (!tree.args.isEmpty) {
- //System.err.println("ARGS: " + unit.source.dbg(tree.args0.head.pos));
+ //Console.err.println("ARGS: " + unit.source.dbg(tree.args0.head.pos));
}
build(tree.fun)
build(tree.args)
case tree: Apply =>
- //System.err.println("NORM_APPLY: " + tree + " " + unit.source.dbg(tree.pos));
+ //Console.err.println("NORM_APPLY: " + tree + " " + unit.source.dbg(tree.pos));
build(tree.fun)
build(tree.args)
case tree: GenericApply =>
- //System.err.println("GEN_APPLY: " + tree + " " + unit.source.dbg(tree.pos));
+ //Console.err.println("GEN_APPLY: " + tree + " " + unit.source.dbg(tree.pos));
build(tree.fun)
build(tree.args)
case tree: Typed =>
@@ -443,8 +445,8 @@ class SemanticTokens(val compiler: Global) {
case tree: Block =>
if (false) {
if (!tree.stats.isEmpty)
- System.err.println("BLOCKS: " + tree.stats.head + " " + tree.stats.head.getClass());
- System.err.println("BLOCKE: " + tree.expr + " " + tree.expr.getClass())
+ Console.err.println("BLOCKS: " + tree.stats.head + " " + tree.stats.head.getClass());
+ Console.err.println("BLOCKE: " + tree.expr + " " + tree.expr.getClass())
}
build(tree.stats)
build(tree.expr)
@@ -456,7 +458,7 @@ class SemanticTokens(val compiler: Global) {
case tree : Assign => build(tree.lhs); build(tree.rhs);
case tree : If => build(tree.cond); build(tree.thenp); build(tree.elsep);
case tree : New =>
- //System.err.println("NEW: " + tree.tpt + " " + tree.tpt.getClass());
+ //Console.err.println("NEW: " + tree.tpt + " " + tree.tpt.getClass());
build(tree.tpt);
case tree : Match => build(tree.selector); build(tree.cases);
case tree : Return => build(tree.expr);
@@ -465,11 +467,11 @@ class SemanticTokens(val compiler: Global) {
case tree : Try => build(tree.block); build(tree.catches); build(tree.finalizer);
case tree : Alternative => build(tree.trees);
case tree : This =>
- //System.err.println("THIS: " + tree.symbol + " " + tree.qual + " " + unit.source.dbg(tree.pos) + " " + tree.tpe);
+ //Console.err.println("THIS: " + tree.symbol + " " + tree.qual + " " + unit.source.dbg(tree.pos) + " " + tree.tpe);
if (tree.symbol != null) buildUse(tree.symbol, tree.pos, tree.tpe);
//Thread.dumpStack();
case tree : AliasTypeDef =>
- //System.err.println("ALIAS: " + tree);
+ //Console.err.println("ALIAS: " + tree);
build(tree.rhs); build(tree.tparams); buildDef(tree.symbol, tree.pos);
case tree : DocDef => build(tree.definition);
case tree: Import => build(tree.expr)
@@ -479,7 +481,7 @@ class SemanticTokens(val compiler: Global) {
case tree: Literal => ;
case EmptyTree => ;
case _ => ;
- System.err.println("BAIL: " + unit.source.dbg(tree0.pos) + " " + tree0 + " " + tree0.getClass());
+ Console.err.println("BAIL: " + unit.source.dbg(tree0.pos) + " " + tree0 + " " + tree0.getClass());
}
} catch {
case t: Throwable =>
@@ -493,7 +495,7 @@ class SemanticTokens(val compiler: Global) {
if (term.hasFlag(Flags.ACCESSOR))
buildSym(analyzer.underlying(term), pos, isDef, tpe)
else if (pos == NoPos) {
- //System.err.println("NOPOS: " + term)
+ //Console.err.println("NOPOS: " + term)
//Thread.dumpStack()
}
else if (term != NoSymbol) {
@@ -504,15 +506,15 @@ class SemanticTokens(val compiler: Global) {
if (cs.length + pos > buf.length) return
else while (idx < cs.length) {
if (buf(pos + idx) != cs(idx)) {
- //System.err.println("MISMATCH: " + name + "[" + idx + "] " + unit.source.dbg(pos));
+ //Console.err.println("MISMATCH: " + name + "[" + idx + "] " + unit.source.dbg(pos));
//Thread.dumpStack();
return;
}
else idx = idx + 1;
}
if (cs.length + pos + 1 < buf.length) {
- if (Character.isJavaIdentifierPart(buf(pos + cs.length))) {
- //System.err.println("MISMATCH: " + name + "[last] " + unit.source.dbg(pos));
+ if (isJavaIdentifierPart(buf(pos + cs.length))) {
+ //Console.err.println("MISMATCH: " + name + "[last] " + unit.source.dbg(pos));
return;
}
}
@@ -527,7 +529,7 @@ class SemanticTokens(val compiler: Global) {
val buf = unit.source.content
if (tree.pos >= buf.length) {
if (false) {
- System.err.println("" + tree + "@" + tree.pos + " not in " +
+ Console.err.println("" + tree + "@" + tree.pos + " not in " +
unit.source.file.name + "[" + buf.length + "]");
Thread.dumpStack()
throw new Error()
@@ -539,7 +541,7 @@ class SemanticTokens(val compiler: Global) {
if (buf(tree.pos) != '.') tree.pos
else {
def f(x : Int) : Int = {
- if (Character.isWhitespace(buf(x))) f(x + 1)
+ if (buf(x).isWhitespace) f(x + 1)
else x
}
f(tree.pos + 1)
@@ -592,10 +594,10 @@ class SemanticTokens(val compiler: Global) {
sem.symbol.pos == tok.symbol.pos) return;
if (false) {
- System.err.println("NOT_GAP: " + sem.symbol + " " + sem.symbol.getClass() + " " + unit.source.dbg(sem.symbol.pos) + " " + sem.symbol.flags);
- System.err.println("NOT_GAP: " + tok.symbol + " " + tok.symbol.getClass() + " " + unit.source.dbg(tok.symbol.pos) + " " + tok.symbol.flags);
- System.err.println("LIST: " + this);
- System.err.println("POS: " + unit.source.dbg(offset));
+ Console.err.println("NOT_GAP: " + sem.symbol + " " + sem.symbol.getClass() + " " + unit.source.dbg(sem.symbol.pos) + " " + sem.symbol.flags);
+ Console.err.println("NOT_GAP: " + tok.symbol + " " + tok.symbol.getClass() + " " + unit.source.dbg(tok.symbol.pos) + " " + tok.symbol.flags);
+ Console.err.println("LIST: " + this);
+ Console.err.println("POS: " + unit.source.dbg(offset));
Thread.dumpStack();
throw new Error();
@@ -603,9 +605,9 @@ class SemanticTokens(val compiler: Global) {
} else {
val gap = cursor.token.asInstanceOf[Gap];
if (!(offset - cursor.offset + tok.length <= gap.length)) {
- System.err.println("LIST =" + this);
- System.err.println("OFFSET=" + offset + " " + tok + " " + tok.length);
- System.err.println(" " + cursor.offset + " " + gap.length);
+ Console.err.println("LIST =" + this);
+ Console.err.println("OFFSET=" + offset + " " + tok + " " + tok.length);
+ Console.err.println(" " + cursor.offset + " " + gap.length);
throw new Error();
}
if (offset == cursor.offset) {
diff --git a/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala b/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala
index 8713947d68..8c59c21f19 100644
--- a/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala
+++ b/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala
@@ -7,6 +7,8 @@
// $Id$
package scala.tools.nsc.reporters
+
+import compat.StringBuilder
import scala.tools.nsc.util.{FakePos, Position}
import java.io.BufferedReader
@@ -39,9 +41,7 @@ class ConsoleReporter(reader : BufferedReader, writer : PrintWriter) extends Abs
//########################################################################
// Public Constructors
- def this() = this(
- new BufferedReader(new InputStreamReader(System.in)),
- new PrintWriter(System.err, true))
+ def this() = this(Console.in, new PrintWriter(Console.err, true))
//########################################################################
// Public Methods - Count
@@ -71,7 +71,7 @@ class ConsoleReporter(reader : BufferedReader, writer : PrintWriter) extends Abs
def printMessage(posIn : Position, msg : String) : Unit = {
if (posIn != null) {
val pos = posIn.inUltimateSource
- val buf = new StringBuffer(msg)
+ val buf = new StringBuilder(msg)
buf.insert(0, " ")
if (pos.line != Position.NOLINE)
buf.insert(0, ":" + pos.line)
@@ -95,7 +95,7 @@ class ConsoleReporter(reader : BufferedReader, writer : PrintWriter) extends Abs
}
/** Prints the column marker of the given position. */
def printColumnMarker(pos : Position) = if (pos != null) {
- val buffer = new StringBuffer(pos.column)
+ val buffer = new StringBuilder(pos.column)
var i = 1
while (i < pos.column) {
buffer.append(' ')
diff --git a/src/compiler/scala/tools/nsc/symtab/Constants.scala b/src/compiler/scala/tools/nsc/symtab/Constants.scala
index 75d781df72..8dbc4c90cb 100644
--- a/src/compiler/scala/tools/nsc/symtab/Constants.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Constants.scala
@@ -6,6 +6,10 @@
package scala.tools.nsc.symtab
+
+import java.lang.Integer.toOctalString
+import compat.StringBuilder
+
import classfile.PickleFormat._
trait Constants requires SymbolTable {
@@ -194,10 +198,10 @@ trait Constants requires SymbolTable {
def escapedStringValue: String = {
def escape(text: String): String = {
- val buf = new StringBuffer
+ val buf = new StringBuilder
for (val c <- Iterator.fromString(text))
- if (Character.isISOControl(c))
- buf.append("\\0" + Integer.toOctalString(c.asInstanceOf[Int]))
+ if (c.isControl)
+ buf.append("\\0" + toOctalString(c.asInstanceOf[Int]))
else
buf.append(c)
buf.toString
diff --git a/src/compiler/scala/tools/nsc/symtab/Definitions.scala b/src/compiler/scala/tools/nsc/symtab/Definitions.scala
index ff67a62b3c..da4a1cd384 100644
--- a/src/compiler/scala/tools/nsc/symtab/Definitions.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Definitions.scala
@@ -271,7 +271,8 @@ trait Definitions requires SymbolTable {
if (module) sym.info.member(fullname.subName(i, j)).suchThat(.hasFlag(MODULE))
else sym.info.member(fullname.subName(i, j).toTypeName)
if (result == NoSymbol) {
- if (settings.debug.value) { System.out.println(sym.info); System.out.println(sym.info.members) }//debug
+ if (settings.debug.value)
+ { Console.println(sym.info); Console.println(sym.info.members) }//debug
throw new FatalError((if (module) "object " else "class ") + fullname + " not found.")
}
result
@@ -476,7 +477,7 @@ trait Definitions requires SymbolTable {
else flatNameString(sym.owner, separator) + "$" + sym.simpleName;
def signature1(etp: Type): String = {
if (etp.symbol == ArrayClass) "[" + signature1(erasure(etp.typeArgs.head))
- else if (isValueClass(etp.symbol)) String.valueOf(abbrvTag(etp.symbol))
+ else if (isValueClass(etp.symbol)) abbrvTag(etp.symbol).toString()
else "L" + flatNameString(etp.symbol, '/') + ";"
}
val etp = erasure(tp)
@@ -531,8 +532,9 @@ trait Definitions requires SymbolTable {
AllClass = newClass(ScalaPackageClass, nme.Nothing, anyparam)
.setFlag(ABSTRACT | TRAIT | FINAL)
- ClassClass = getClass("java.lang.Class")
StringClass = getClass("java.lang.String")
+
+ ClassClass = getClass("java.lang.Class")
ThrowableClass = getClass("java.lang.Throwable")
NullPointerExceptionClass = getClass("java.lang.NullPointerException")
NonLocalReturnExceptionClass = getClass("scala.runtime.NonLocalReturnException")
diff --git a/src/compiler/scala/tools/nsc/symtab/Names.scala b/src/compiler/scala/tools/nsc/symtab/Names.scala
index 0d868c8537..dc73601a48 100644
--- a/src/compiler/scala/tools/nsc/symtab/Names.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Names.scala
@@ -70,7 +70,7 @@ class Names {
while (i < len) {
if (nc + i == chrs.length) {
val newchrs = new Array[char](chrs.length * 2)
- System.arraycopy(chrs, 0, newchrs, 0, chrs.length)
+ Array.copy(chrs, 0, newchrs, 0, chrs.length)
chrs = newchrs
}
chrs(nc + i) = cs(offset + i)
@@ -178,7 +178,7 @@ class Names {
* @param offset ...
*/
final def copyChars(cs: Array[char], offset: int) =
- System.arraycopy(chrs, index, cs, offset, len)
+ Array.copy(chrs, index, cs, offset, len)
/** return the ascii representation of this name
*/
diff --git a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala
index fd9fecad8c..be4c397d7d 100644
--- a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala
+++ b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala
@@ -6,6 +6,7 @@
package scala.tools.nsc.symtab
+import compat.Platform.currentTime
import java.io.{File, IOException}
import scala.collection.mutable.HashMap
@@ -50,7 +51,7 @@ abstract class SymbolLoaders {
override def complete(root: Symbol): unit = {
try {
- val start = System.currentTimeMillis()
+ val start = currentTime
val currentphase = phase
doComplete(root)
phase = currentphase
diff --git a/src/compiler/scala/tools/nsc/symtab/SymbolTable.scala b/src/compiler/scala/tools/nsc/symtab/SymbolTable.scala
index 8556e54cef..ccc33587dd 100644
--- a/src/compiler/scala/tools/nsc/symtab/SymbolTable.scala
+++ b/src/compiler/scala/tools/nsc/symtab/SymbolTable.scala
@@ -18,7 +18,7 @@ abstract class SymbolTable extends Names
{
def settings: Settings
def rootLoader: LazyType
- def log(msg: Object): unit
+ def log(msg: AnyRef): unit
/** Are we compiling for the J2ME CLDC platform? */
def forCLDC: Boolean
diff --git a/src/compiler/scala/tools/nsc/symtab/Symbols.scala b/src/compiler/scala/tools/nsc/symtab/Symbols.scala
index 58276f2a42..cd8d3c2ea2 100644
--- a/src/compiler/scala/tools/nsc/symtab/Symbols.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Symbols.scala
@@ -58,7 +58,7 @@ trait Symbols requires SymbolTable {
else if (isClass) ret = ret + ("class").length()
else if (isModule) ret = ret + ("object").length()
else ret = ret + ("var").length()
- while (Character.isWhitespace(buf(ret))) ret = ret + 1
+ while (buf(ret).isWhitespace) ret = ret + 1
ret
}
else if (isValue) {
@@ -68,7 +68,7 @@ trait Symbols requires SymbolTable {
(buf(pos + 2) == 'l') &&
(buf(pos + 3) == ' ')) {
var pos0 = pos + 4
- while (pos0 < buf.length && Character.isWhitespace(buf(pos0)))
+ while (pos0 < buf.length && buf(pos0).isWhitespace)
pos0 = pos0 + 1
pos0
diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala
index 0f101322b4..680aec5c5b 100644
--- a/src/compiler/scala/tools/nsc/symtab/Types.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Types.scala
@@ -6,6 +6,7 @@
package scala.tools.nsc.symtab
+import compat.Platform.currentTime
import scala.collection.mutable.ListBuffer
import scala.tools.nsc.util.{HashSet, Position}
import Flags._
@@ -225,7 +226,7 @@ trait Types requires SymbolTable {
}
*/
case _ =>
- //System.out.println("" + this + ".memberType(" + sym +":" + sym.tpe +")" + sym.ownerChain);//DEBUG
+ //Console.println("" + this + ".memberType(" + sym +":" + sym.tpe +")" + sym.ownerChain);//DEBUG
sym.tpe.asSeenFrom(this, sym.owner)
}
}
@@ -258,13 +259,13 @@ trait Types requires SymbolTable {
/** Is this type a subtype of that type? */
def <:<(that: Type): boolean = {
if (util.Statistics.enabled) subtypeCount = subtypeCount + 1
- val startTime = if (util.Statistics.enabled) System.currentTimeMillis() else 0l
+ val startTime = if (util.Statistics.enabled) currentTime else 0l
val result =
((this eq that) ||
(if (explainSwitch) explain("<", isSubType, this, that)
else isSubType(this, that)));
if (util.Statistics.enabled)
- subtypeMillis = subtypeMillis + System.currentTimeMillis() - startTime
+ subtypeMillis = subtypeMillis + currentTime - startTime
result
}
@@ -370,7 +371,7 @@ trait Types requires SymbolTable {
val this1 = adaptToNewRunMap(this)
if (this1 eq this) sym.validTo = period(currentRunId, phaseId(sym.validTo))
else {
- //System.out.println("new type of " + sym + "=" + this1 + ", used to be " + this);//DEBUG
+ //Console.println("new type of " + sym + "=" + this1 + ", used to be " + this);//DEBUG
sym.setInfo(this1)
}
}
@@ -409,9 +410,9 @@ trait Types requires SymbolTable {
//TODO: use narrow only for modules? (correct? efficiency gain?)
def findMember(name: Name, excludedFlags: int, requiredFlags: long, stableOnly: boolean): Symbol = {
if (util.Statistics.enabled) findMemberCount = findMemberCount + 1
- val startTime = if (util.Statistics.enabled) System.currentTimeMillis() else 0l
+ val startTime = if (util.Statistics.enabled) currentTime else 0l
- //System.out.println("find member " + name.decode + " in " + this + ":" + this.baseClasses)//DEBUG
+ //Console.println("find member " + name.decode + " in " + this + ":" + this.baseClasses)//DEBUG
var members: Scope = null
var member: Symbol = NoSymbol
var excluded = excludedFlags | DEFERRED
@@ -435,7 +436,7 @@ trait Types requires SymbolTable {
if (name.isTypeName || stableOnly) {
checkMalformedSwitch = savedCheckMalformedSwitch
if (util.Statistics.enabled)
- findMemberMillis = findMemberMillis + System.currentTimeMillis() - startTime
+ findMemberMillis = findMemberMillis + currentTime - startTime
return sym
} else if (member == NoSymbol) {
member = sym
@@ -476,7 +477,7 @@ trait Types requires SymbolTable {
} // while (continue)
checkMalformedSwitch = savedCheckMalformedSwitch
if (util.Statistics.enabled)
- findMemberMillis = findMemberMillis + System.currentTimeMillis() - startTime
+ findMemberMillis = findMemberMillis + currentTime - startTime
if (members == null) {
if (util.Statistics.enabled) if (member == NoSymbol) noMemberCount = noMemberCount + 1;
member
@@ -668,7 +669,7 @@ trait Types requires SymbolTable {
try {
if (util.Statistics.enabled)
compoundClosureCount = compoundClosureCount + 1
- //System.out.println("computing closure of " + symbol.tpe + " " + parents)//DEBUG
+ //Console.println("computing closure of " + symbol.tpe + " " + parents)//DEBUG
val buf = new ListBuffer[Type]
buf += symbol.tpe
var clSize = 1
@@ -713,7 +714,7 @@ trait Types requires SymbolTable {
}
closureCache = new Array[Type](clSize)
buf.copyToArray(closureCache, 0)
- //System.out.println("closureCache of " + symbol.tpe + " = " + List.fromArray(closureCache))//DEBUG
+ //Console.println("closureCache of " + symbol.tpe + " = " + List.fromArray(closureCache))//DEBUG
var j = 0
while (j < clSize) {
closureCache(j) match {
@@ -729,7 +730,7 @@ trait Types requires SymbolTable {
}
j = j + 1
}
- //System.out.println("closure of " + symbol.tpe + " = " + List.fromArray(closureCache))//DEBUG
+ //Console.println("closure of " + symbol.tpe + " = " + List.fromArray(closureCache))//DEBUG
closureCache
} catch {
case ex: MalformedClosure =>
@@ -744,7 +745,7 @@ trait Types requires SymbolTable {
closureCache = null
closureCache = computeClosure
}
- //System.out.println("closure(" + symbol + ") = " + List.fromArray(closureCache));//DEBUG
+ //Console.println("closure(" + symbol + ") = " + List.fromArray(closureCache));//DEBUG
}
if (closureCache == null)
throw new TypeError("illegal cyclic reference involving " + symbol)
@@ -755,7 +756,7 @@ trait Types requires SymbolTable {
def computeBaseClasses: List[Symbol] =
if (parents.isEmpty) List(symbol)
else {
- //System.out.println("computing base classes of " + symbol + " at phase " + phase);//DEBUG
+ //Console.println("computing base classes of " + symbol + " at phase " + phase);//DEBUG
// optimized, since this seems to be performance critical
val superclazz = parents.head
var mixins = parents.tail
@@ -1267,8 +1268,8 @@ trait Types requires SymbolTable {
case PolyType(tparams, restpe) => restpe.subst(tparams, args)
case ErrorType => tycon
case _ =>
- System.out.println(tycon.getClass())
- System.out.println(tycon.$tag())
+ Console.println(tycon.getClass())
+ Console.println(tycon.$tag())
throw new Error()
}
@@ -1488,7 +1489,7 @@ trait Types requires SymbolTable {
if (symclazz == clazz && (pre.widen.symbol isNonBottomSubClass symclazz))
pre.baseType(symclazz) match {
case TypeRef(_, basesym, baseargs) =>
-// System.out.println("instantiating " + sym + " from " + basesym + " with " + basesym.typeParams + " and " + baseargs);//DEBUG
+// Console.println("instantiating " + sym + " from " + basesym + " with " + basesym.typeParams + " and " + baseargs);//DEBUG
if (basesym.typeParams.length != baseargs.length)
throw new TypeError(
"something is wrong (wrong class file?): "+basesym+
@@ -1782,7 +1783,7 @@ trait Types requires SymbolTable {
sym1 != NoSymbol &&
sym1.info =:= sym2.info.substThis(sym2.owner, sym1.owner.thisType)
}
- //System.out.println("is same? " + tp1 + " " + tp2 + " " + tp1.symbol.owner + " " + tp2.symbol.owner)//DEBUG
+ //Console.println("is same? " + tp1 + " " + tp2 + " " + tp1.symbol.owner + " " + tp2.symbol.owner)//DEBUG
isSameTypes(parents1, parents2) && isSubScope(ref1, ref2) && isSubScope(ref2, ref1)
case Pair(MethodType(pts1, res1), MethodType(pts2, res2)) =>
(pts1.length == pts2.length &&
@@ -1858,7 +1859,7 @@ trait Types requires SymbolTable {
case Pair(ConstantType(_), ConstantType(_)) => tp1 =:= tp2
case Pair(TypeRef(pre1, sym1, args1), TypeRef(pre2, sym2, args2)) =>
- //System.out.println("isSubType " + tp1 + " " + tp2);//DEBUG
+ //Console.println("isSubType " + tp1 + " " + tp2);//DEBUG
def isSubArgs(tps1: List[Type], tps2: List[Type],
tparams: List[Symbol]): boolean = (
tps1.isEmpty && tps2.isEmpty
@@ -1883,7 +1884,7 @@ trait Types requires SymbolTable {
||
sym1 == AllClass
||
- // System.out.println("last chance " + sym1 + " " + sym2 + " " + sym2.isClass + " " (sym2 isSubClass ObjectClass))
+ // Console.println("last chance " + sym1 + " " + sym2 + " " + sym2.isClass + " " (sym2 isSubClass ObjectClass))
sym1 == AllRefClass && sym2.isClass && (sym2 isSubClass ObjectClass))
case Pair(MethodType(pts1, res1), MethodType(pts2, res2)) =>
(pts1.length == pts2.length &&
@@ -2004,7 +2005,7 @@ trait Types requires SymbolTable {
private def addClosure(tp: Type, cl: Array[Type]): Array[Type] = {
val cl1 = new Array[Type](cl.length + 1)
cl1(0) = tp
- System.arraycopy(cl, 0, cl1, 1, cl.length)
+ Array.copy(cl, 0, cl1, 1, cl.length)
cl1
}
@@ -2464,11 +2465,11 @@ trait Types requires SymbolTable {
* <code>arg2</code> and print trace of computation.
*/
private def explain[T](op: String, p: (Type, T) => boolean, tp1: Type, arg2: T): boolean = {
- System.out.println(indent + tp1 + " " + op + " " + arg2 + "?")
+ Console.println(indent + tp1 + " " + op + " " + arg2 + "?")
indent = indent + " "
val result = p(tp1, arg2)
indent = indent.substring(0, indent.length() - 2)
- System.out.println(indent + result)
+ Console.println(indent + result)
result
}
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/AbstractFileReader.scala b/src/compiler/scala/tools/nsc/symtab/classfile/AbstractFileReader.scala
index 0163ea5724..acf1d5fea5 100644
--- a/src/compiler/scala/tools/nsc/symtab/classfile/AbstractFileReader.scala
+++ b/src/compiler/scala/tools/nsc/symtab/classfile/AbstractFileReader.scala
@@ -11,7 +11,9 @@ package scala.tools.nsc.symtab.classfile
import scala.tools.nsc.io.{AbstractFile, PlainFile, ZipArchive}
-import java.io.{File, FileInputStream, IOException};
+import java.lang.Float.intBitsToFloat
+import java.lang.Double.longBitsToDouble
+import java.io.{File, FileInputStream, IOException}
/** this class reads files byte per byte. Only used by ClassFileParser
*/
@@ -75,11 +77,11 @@ class AbstractFileReader(val file: AbstractFile) {
/** extract a float at position bp from buf
*/
- def getFloat(mybp: Int): Float = Float.intBitsToFloat(getInt(mybp))
+ def getFloat(mybp: Int): Float = intBitsToFloat(getInt(mybp))
/** extract a double at position bp from buf
*/
- def getDouble(mybp: Int): Double = Double.longBitsToDouble(getLong(mybp))
+ def getDouble(mybp: Int): Double = longBitsToDouble(getLong(mybp))
/** skip next 'n' bytes
*/
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
index c53e400b4a..1bd9c4789f 100644
--- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
+++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
@@ -21,6 +21,7 @@ import scala.tools.nsc.io.AbstractFile
import scala.collection.mutable.{ListBuffer, ArrayBuffer}
import scala.collection.immutable.{Map, ListMap}
+import java.lang.Integer.toHexString
import java.io.IOException
/** This abstract class implements a class file parser.
@@ -97,8 +98,8 @@ abstract class ClassfileParser {
val magic = in.nextInt
if (magic != JAVA_MAGIC)
throw new IOException("class file '" + in.file + "' "
- + "has wrong magic number 0x" + Integer.toHexString(magic)
- + ", should be 0x" + Integer.toHexString(JAVA_MAGIC))
+ + "has wrong magic number 0x" + toHexString(magic)
+ + ", should be 0x" + toHexString(JAVA_MAGIC))
val minorVersion = in.nextChar
val majorVersion = in.nextChar
if ((majorVersion < JAVA_MAJOR_VERSION) ||
@@ -114,7 +115,7 @@ abstract class ClassfileParser {
class ConstantPool {
private val len = in.nextChar
private val starts = new Array[int](len)
- private val values = new Array[Object](len)
+ private val values = new Array[AnyRef](len)
private val internalized = new Array[Name](len)
{ var i = 1
while (i < starts.length) {
@@ -369,7 +370,7 @@ abstract class ClassfileParser {
if ((instanceDefs.lookup(nme.CONSTRUCTOR) == NoSymbol &&
(sflags & INTERFACE) == 0))
{
- //System.out.println("adding constructor to " + clazz);//DEBUG
+ //Console.println("adding constructor to " + clazz);//DEBUG
instanceDefs.enter(
clazz.newConstructor(NoPos)
.setFlag(clazz.flags & ConstrFlags)
@@ -436,7 +437,9 @@ abstract class ClassfileParser {
private def polySigToType(sym: Symbol, sig: Name): Type =
try { polySigToType0(sym, sig) }
catch {
- case e: Throwable => System.err.println("" + sym + " - " + sig); throw e
+ case e: Throwable =>
+ Console.err.println("" + sym + " - " + sig);
+ throw e
}
private def polySigToType0(sym: Symbol, sig: Name): Type = {
var index = 0
@@ -591,7 +594,7 @@ abstract class ClassfileParser {
val c = pool.getConstant(in.nextChar)
val c1 = convertTo(c, symtype)
if (c1 != null) sym.setInfo(ConstantType(c1))
- else System.out.println("failure to convert "+c+" to "+symtype);//debug
+ else Console.println("failure to convert " + c + " to " + symtype); //debug
case nme.InnerClassesATTR =>
if (!isScala) parseInnerClasses() else in.skip(attrLen)
case nme.ScalaSignatureATTR =>
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/PickleBuffer.scala b/src/compiler/scala/tools/nsc/symtab/classfile/PickleBuffer.scala
index e189e65863..fb8a3a5ed8 100644
--- a/src/compiler/scala/tools/nsc/symtab/classfile/PickleBuffer.scala
+++ b/src/compiler/scala/tools/nsc/symtab/classfile/PickleBuffer.scala
@@ -21,7 +21,7 @@ class PickleBuffer(data: Array[byte], from: int, to: int) {
/** Double bytes array */
private def dble: unit = {
val bytes1 = new Array[byte](bytes.length * 2)
- System.arraycopy(bytes, 0, bytes1, 0, writeIndex)
+ Array.copy(bytes, 0, bytes1, 0, writeIndex)
bytes = bytes1
}
@@ -60,7 +60,7 @@ class PickleBuffer(data: Array[byte], from: int, to: int) {
def patchNat(pos: int, x: int): unit = {
def patchNatPrefix(x: int): unit = {
writeByte(0)
- System.arraycopy(bytes, pos, bytes, pos+1, writeIndex - (pos+1))
+ Array.copy(bytes, pos, bytes, pos+1, writeIndex - (pos+1))
bytes(pos) = ((x & 0x7f) | 0x80).asInstanceOf[byte]
val y = x >>> 7
if (y != 0) patchNatPrefix(y)
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala
index 8e50764b8d..7a9f044064 100644
--- a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala
+++ b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala
@@ -85,7 +85,7 @@ abstract class Pickler extends SubComponent {
case None =>
if (ep == entries.length) {
val entries1 = new Array[AnyRef](ep * 2)
- System.arraycopy(entries, 0, entries1, 0, ep)
+ Array.copy(entries, 0, entries1, 0, ep)
entries = entries1
}
entries(ep) = entry
diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala
index 2f1b5e8df4..b174e5747a 100644
--- a/src/compiler/scala/tools/nsc/transform/Erasure.scala
+++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala
@@ -189,8 +189,8 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer {
def unboxOp(tp: Type): Name = {
val clazzName = tp.symbol.name.toString()
newTermName(
- String.valueOf((clazzName.charAt(0) + ('a' - 'A')).asInstanceOf[char]) +
- clazzName.substring(1) + "Value")
+ //String.valueOf((clazzName.charAt(0) + ('a' - 'A')).asInstanceOf[char]) +
+ clazzName.charAt(0).toLowerCase + clazzName.substring(1) + "Value")
}
/** Unbox `tree' of boxed type to expected type `pt' */
@@ -214,7 +214,7 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer {
else
Literal(signature(pt.typeArgs.head));
*/
- //System.out.println("unboxing " + tree + ":" + tree.tpe + " to " + pt);//DEBUG
+ //Console.println("unboxing " + tree + ":" + tree.tpe + " to " + pt);//DEBUG
//gen.mkRuntimeCall(nme.arrayValue, List(tree1, elemTag))
gen.mkRuntimeCall(nme.arrayValue, List(tree1, Literal(pt.typeArgs.head)))
} else {
@@ -395,7 +395,7 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer {
} catch {
case ex: Throwable =>
//if (settings.debug.value)
- System.out.println("exception when typing " + tree);
+ Console.println("exception when typing " + tree);
throw ex
}
def adaptCase(cdef: CaseDef): CaseDef = {
@@ -653,7 +653,7 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer {
case Template(parents, body) =>
assert(!currentOwner.isImplClass)
- //System.out.println("checking no dble defs " + tree)//DEBUG
+ //Console.println("checking no dble defs " + tree)//DEBUG
checkNoDoubleDefs(tree.symbol.owner)
copy.Template(tree, parents, addBridges(body, currentOwner))
case _ =>
diff --git a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala
index 213945325b..091c4e4655 100644
--- a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala
+++ b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala
@@ -191,7 +191,7 @@ abstract class ExplicitOuter extends InfoTransform with TransMatcher with Patter
super.transform(tree)
} catch {//debug
case ex: Throwable =>
- System.out.println("exception when transforming " + tree)
+ Console.println("exception when transforming " + tree)
throw ex
} finally {
outerParam = savedOuterParam
diff --git a/src/compiler/scala/tools/nsc/transform/LambdaLift.scala b/src/compiler/scala/tools/nsc/transform/LambdaLift.scala
index d259a1468a..d47a209ebe 100644
--- a/src/compiler/scala/tools/nsc/transform/LambdaLift.scala
+++ b/src/compiler/scala/tools/nsc/transform/LambdaLift.scala
@@ -219,7 +219,7 @@ abstract class LambdaLift extends InfoTransform {
super.traverse(tree)
} catch {//debug
case ex: Throwable =>
- System.out.println("exception when traversing " + tree)
+ Console.println("exception when traversing " + tree)
throw ex
}
}
diff --git a/src/compiler/scala/tools/nsc/transform/Mixin.scala b/src/compiler/scala/tools/nsc/transform/Mixin.scala
index d5319834ea..dbaef1d3e4 100644
--- a/src/compiler/scala/tools/nsc/transform/Mixin.scala
+++ b/src/compiler/scala/tools/nsc/transform/Mixin.scala
@@ -180,7 +180,7 @@ abstract class Mixin extends InfoTransform {
// first complete the superclass with mixed in members
addMixedinMembers(clazz.superClass)
- //System.out.println("adding members of " + clazz.info.baseClasses.tail.takeWhile(superclazz !=) + " to " + clazz);//DEBUG
+ //Console.println("adding members of " + clazz.info.baseClasses.tail.takeWhile(superclazz !=) + " to " + clazz);//DEBUG
/** Mix in members of implementation class mixinClass into class clazz */
def mixinImplClassMembers(impl: Symbol, iface: Symbol): unit = {
@@ -648,7 +648,7 @@ abstract class Mixin extends InfoTransform {
atPhase(phase.next)(postTransform(tree1))
} catch {
case ex: Throwable =>
- System.out.println("exception when traversing " + tree)
+ Console.println("exception when traversing " + tree)
throw ex
}
}
diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
index c8a735a2e5..be832a0a49 100644
--- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala
+++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
@@ -95,7 +95,7 @@ abstract class UnCurry extends InfoTransform with TypingTransformers {
postTransform(mainTransform(tree))
} catch {
case ex: Throwable =>
- System.out.println("exception when traversing " + tree)
+ Console.println("exception when traversing " + tree)
throw ex
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/ConstantFolder.scala b/src/compiler/scala/tools/nsc/typechecker/ConstantFolder.scala
index 49d06a16fc..adb314cf1e 100644
--- a/src/compiler/scala/tools/nsc/typechecker/ConstantFolder.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/ConstantFolder.scala
@@ -6,6 +6,9 @@
package scala.tools.nsc.typechecker
+
+import java.lang.ArithmeticException
+
/** This class ...
*
* @author Martin Odersky
diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
index 0d2d65567d..f85be9d6d7 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
@@ -334,13 +334,13 @@ trait Infer requires Analyzer {
val sym1 = sym filter (alt => context.isAccessible(alt, pre, site.isInstanceOf[Super]))
if (sym1 == NoSymbol) {
if (settings.debug.value) {
- System.out.println(context)
- System.out.println(tree)
- System.out.println("" + pre + " " + sym.owner + " " + context.owner + " " + context.outer.enclClass.owner + " " + sym.owner.thisType + (pre =:= sym.owner.thisType))
+ Console.println(context)
+ Console.println(tree)
+ Console.println("" + pre + " " + sym.owner + " " + context.owner + " " + context.outer.enclClass.owner + " " + sym.owner.thisType + (pre =:= sym.owner.thisType))
}
accessError("")
} else {
- //System.out.println("check acc " + sym1 + ":" + sym1.tpe + " from " + pre);//DEBUG
+ //Console.println("check acc " + sym1 + ":" + sym1.tpe + " from " + pre);//DEBUG
var owntype = try{
pre.memberType(sym1)
} catch {
@@ -414,7 +414,7 @@ trait Infer requires Analyzer {
/** Map type variable to its instance, or, if `variance' is covariant/contravariant,
* to its upper/lower bound */
def instantiateToBound(tvar: TypeVar, variance: int): Type = try {
- //System.out.println("instantiate "+tvar+tvar.constr+" variance = "+variance);//DEBUG
+ //Console.println("instantiate "+tvar+tvar.constr+" variance = "+variance);//DEBUG
if (tvar.constr.inst != NoType) {
instantiate(tvar.constr.inst)
} else if ((variance & COVARIANT) != 0 && !tvar.constr.hibounds.isEmpty) {
@@ -729,7 +729,7 @@ trait Infer requires Analyzer {
"\n --- because ---\n" + ex.getMessage())
}
def instError = {
- if (settings.debug.value) System.out.println("ici " + tree + " " + undetparams + " " + pt)
+ if (settings.debug.value) Console.println("ici " + tree + " " + undetparams + " " + pt)
if (settings.explaintypes.value) explainTypes(restpe.subst(undetparams, tvars), pt)
errorTree(tree, "constructor cannot be instantiated to expected type" +
foundReqMsg(restpe, pt))
@@ -750,9 +750,9 @@ trait Infer requires Analyzer {
val pt1 = pt.subst(ptparams, ptvars)
if (isPopulated(restpe, pt1)) {
ptvars foreach instantiateTypeVar
- } else { if (settings.debug.value) System.out.println("no instance: "); instError }
- } else { if (settings.debug.value) System.out.println("not a subtype " + restpe.subst(undetparams, tvars) + " of " + ptWithWildcards); instError }
- } else { if (settings.debug.value) System.out.println("not fuly defined: " + pt); instError }
+ } else { if (settings.debug.value) Console.println("no instance: "); instError }
+ } else { if (settings.debug.value) Console.println("not a subtype " + restpe.subst(undetparams, tvars) + " of " + ptWithWildcards); instError }
+ } else { if (settings.debug.value) Console.println("not fuly defined: " + pt); instError }
}
def instantiateTypeVar(tvar: TypeVar) = {
@@ -946,7 +946,7 @@ trait Infer requires Analyzer {
if (settings.debug.value) {
tree match {
case Select(qual, _) =>
- System.out.println("qual: " + qual + ":" + qual.tpe +
+ Console.println("qual: " + qual + ":" + qual.tpe +
" with decls " + qual.tpe.decls +
" with members " + qual.tpe.members +
" with members " + qual.tpe.member(newTermName("$minus")))
diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
index 63a3bc9367..581b1f9637 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
@@ -153,7 +153,7 @@ trait Namers requires Analyzer {
val file = context.unit.source.getFile()
val clazz = c.asInstanceOf[ClassSymbol]
if (settings.debug.value && clazz.sourceFile != null && !clazz.sourceFile.equals(file)) {
- System.err.println("SOURCE MISMATCH: " + clazz.sourceFile + " vs. " + file + " SYM=" + c);
+ Console.err.println("SOURCE MISMATCH: " + clazz.sourceFile + " vs. " + file + " SYM=" + c);
}
clazz.sourceFile = file
if (clazz.sourceFile != null) {
@@ -625,7 +625,7 @@ trait Namers requires Analyzer {
}
} catch {
case ex: TypeError =>
- //System.out.println("caught " + ex + " in typeSig")//DEBUG
+ //Console.println("caught " + ex + " in typeSig")//DEBUG
typer.reportTypeError(tree.pos, ex)
ErrorType
}
@@ -682,7 +682,7 @@ trait Namers requires Analyzer {
/* Is type `tp1' properly contained in type `tp2'? */
def isContainedIn(tp1: Type, tp2: Type) = {
- //System.out.println("is " + tp1 + " contained in " + tp2 + "?");//DEBUG
+ //Console.println("is " + tp1 + " contained in " + tp2 + "?");//DEBUG
new ContainsTraverser(tp1).traverse(tp2).result
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
index b2abba5934..728cca7453 100644
--- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
@@ -10,6 +10,8 @@ import symtab.Flags._
import collection.mutable.HashMap
import transform.InfoTransform
+import compat.Math.MIN_INT
+
/** <p>
* Post-attribution checking and transformation.
* </p>
@@ -135,24 +137,24 @@ abstract class RefChecks extends InfoTransform {
(if (otherAccess == "") "public" else "at least "+otherAccess))
}
- //System.out.println(infoString(member) + " overrides " + infoString(other) + " in " + clazz);//DEBUG
+ //Console.println(infoString(member) + " overrides " + infoString(other) + " in " + clazz);//DEBUG
// return if we already checked this combination elsewhere
if (member.owner != clazz) {
if ((member.owner isSubClass other.owner) &&
((member hasFlag DEFERRED) || !(other hasFlag DEFERRED))) {
- //System.out.println(infoString(member) + " shadows1 " + infoString(other) " in " + clazz);//DEBUG
+ //Console.println(infoString(member) + " shadows1 " + infoString(other) " in " + clazz);//DEBUG
return;
}
if (clazz.info.parents exists (parent =>
(parent.symbol isSubClass other.owner) && (parent.symbol isSubClass member.owner) &&
((member hasFlag DEFERRED) || !(other hasFlag DEFERRED)))) {
- //System.out.println(infoString(member) + " shadows2 " + infoString(other) + " in " + clazz);//DEBUG
+ //Console.println(infoString(member) + " shadows2 " + infoString(other) + " in " + clazz);//DEBUG
return;
}
if (clazz.info.parents forall (parent =>
(parent.symbol isSubClass other.owner) == (parent.symbol isSubClass member.owner))) {
- //System.out.println(infoString(member) + " shadows " + infoString(other) + " in " + clazz);//DEBUG
+ //Console.println(infoString(member) + " shadows " + infoString(other) + " in " + clazz);//DEBUG
return;
}
}
@@ -205,7 +207,7 @@ abstract class RefChecks extends InfoTransform {
val opc = new overridingPairs.Cursor(clazz)
while (opc.hasNext) {
- //System.out.println("overrides " + opc.overriding/* + ":" + opc.overriding.tpe*/ + opc.overriding.locationString + " " + opc.overridden/* + ":" + opc.overridden.tpe*/ + opc.overridden.locationString + opc.overridden.hasFlag(DEFERRED));//DEBUG
+ //Console.println("overrides " + opc.overriding/* + ":" + opc.overriding.tpe*/ + opc.overriding.locationString + " " + opc.overridden/* + ":" + opc.overridden.tpe*/ + opc.overridden.locationString + opc.overridden.hasFlag(DEFERRED));//DEBUG
if (!opc.overridden.isClass) checkOverride(clazz, opc.overriding, opc.overridden);
opc.next
@@ -239,7 +241,7 @@ abstract class RefChecks extends InfoTransform {
(clazz.info.baseClasses.tail forall {
bc => member.matchingSymbol(bc, clazz.thisType) == NoSymbol
})) {
- // for (val bc <- clazz.info.baseClasses.tail) System.out.println("" + bc + " has " + bc.info.decl(member.name) + ":" + bc.info.decl(member.name).tpe);//DEBUG
+ // for (val bc <- clazz.info.baseClasses.tail) Console.println("" + bc + " has " + bc.info.decl(member.name) + ":" + bc.info.decl(member.name).tpe);//DEBUG
unit.error(member.pos, member.toString() + " overrides nothing");
member resetFlag OVERRIDE
}
@@ -322,7 +324,7 @@ abstract class RefChecks extends InfoTransform {
var sym = base
var state = CoVariance
while (sym != clazz && state != AnyVariance) {
- //System.out.println("flip: " + sym + " " + sym.isParameter());//DEBUG
+ //Console.println("flip: " + sym + " " + sym.isParameter());//DEBUG
if ((sym hasFlag PARAM) && !sym.owner.isConstructor) state = -state;
else if (!sym.owner.isClass) state = AnyVariance;
else if (sym.isAliasType) state = NoVariance;
@@ -344,7 +346,7 @@ abstract class RefChecks extends InfoTransform {
if (sym.variance != NoVariance) {
val v = relativeVariance(sym);
if (v != AnyVariance && sym.variance != v * variance) {
- //System.out.println("relativeVariance(" + base + "," + sym + ") = " + v);//DEBUG
+ //Console.println("relativeVariance(" + base + "," + sym + ") = " + v);//DEBUG
unit.error(base.pos,
varianceString(sym.variance) + " " + sym +
" occurs in " + varianceString(v * variance) +
@@ -381,7 +383,7 @@ abstract class RefChecks extends InfoTransform {
class LevelInfo(val outer: LevelInfo) {
val scope: Scope = if (outer == null) newScope else newScope(outer.scope)
- var maxindex: int = Integer.MIN_VALUE
+ var maxindex: int = MIN_INT
var refpos: int = _
var refsym: Symbol = _
}
@@ -468,7 +470,7 @@ abstract class RefChecks extends InfoTransform {
case ValDef(_, _, _, _) =>
val tree1 = transform(tree); // important to do before forward reference check
if (tree.symbol.isLocal && index <= currentLevel.maxindex) {
- if (settings.debug.value) System.out.println(currentLevel.refsym);
+ if (settings.debug.value) Console.println(currentLevel.refsym);
unit.error(currentLevel.refpos, "forward reference extends over definition of " + tree.symbol);
}
List(tree1)
@@ -515,7 +517,7 @@ abstract class RefChecks extends InfoTransform {
case _ =>
false
}
- //System.out.println("is irefutable? " + pat + ":" + pat.tpe + " against " + seltpe + ": " + result);//DEBUG
+ //Console.println("is irefutable? " + pat + ":" + pat.tpe + " against " + seltpe + ": " + result);//DEBUG
result
}
@@ -590,7 +592,7 @@ abstract class RefChecks extends InfoTransform {
else qual match {
case Super(qualifier, mix) =>
val base = qual.symbol;
- //System.out.println("super: " + tree + " in " + base);//DEBUG
+ //Console.println("super: " + tree + " in " + base);//DEBUG
assert(!(base.isTrait && sym.isTerm && mix == nme.EMPTY.toTypeName)) // term should have been eliminated by super accessors
case _ =>
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala
index 8be7d250a5..91d5855ac0 100644
--- a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala
@@ -78,7 +78,7 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT
sym.alias) setPos tree.pos
}
if (settings.debug.value)
- System.out.println("alias replacement: " + tree + " ==> " + result);//debug
+ Console.println("alias replacement: " + tree + " ==> " + result);//debug
transform(result)
} else {
if (needsProtectedAccessor(sym, tree.pos)) {
diff --git a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
index 2d963316de..caf0573f3d 100644
--- a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
@@ -152,7 +152,7 @@ trait SyntheticMethods requires Analyzer {
}
def beanSetterOrGetter(sym: Symbol): Symbol =
- if (!Character.isLetter(sym.name(0))) {
+ if (!sym.name(0).isLetter) {
unit.error(sym.pos, "attribute `BeanProperty' can be applied only to fields that start with a letter")
NoSymbol
} else {
@@ -161,7 +161,7 @@ trait SyntheticMethods requires Analyzer {
val prefix = if (sym.isSetter) "set" else
if (sym.tpe.resultType == BooleanClass.tpe) "is" else "get"
val arity = if (sym.isSetter) 1 else 0
- val name1 = prefix + Character.toUpperCase(name0(0)) + name0.subName(1, name0.length)
+ val name1 = prefix + name0(0).toUpperCase + name0.subName(1, name0.length)
val sym1 = clazz.info.decl(name1)
if (sym1 != NoSymbol && sym1.tpe.paramTypes.length == arity) {
unit.error(sym.pos, "a definition of `"+name1+"' already exists in " + clazz)
diff --git a/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala b/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala
index 0e032321e0..dd24c7b32e 100644
--- a/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala
@@ -17,7 +17,7 @@ abstract class TreeCheckers extends Analyzer {
val tpeOfTree = new scala.collection.mutable.HashMap[Tree, Type]
def checkTrees: unit = {
- System.out.println("[consistency check at start of phase " + phase + "]")
+ Console.println("[consistency check at start of phase " + phase + "]")
for (val unit <- currentRun.units) check(unit)
}
@@ -112,7 +112,7 @@ abstract class TreeCheckers extends Analyzer {
} catch {
case ex: Throwable =>
if (settings.debug.value)
- System.out.println("exception when traversing " + tree);
+ Console.println("exception when traversing " + tree);
throw(ex)
}
}
@@ -137,7 +137,7 @@ abstract class TreeCheckers extends Analyzer {
} catch {
case ex: Throwable =>
if (settings.debug.value)
- System.out.println("exception when traversing " + tree);
+ Console.println("exception when traversing " + tree);
throw(ex)
}
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 4a4d6da251..c5d9c68621 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -8,6 +8,7 @@
//todo: use inherited type info also for vars and values
package scala.tools.nsc.typechecker
+import compat.Platform.currentTime
import scala.collection.mutable.{HashMap, ListBuffer}
import scala.tools.nsc.util.{HashSet, Position, Set}
import symtab.Flags._
@@ -633,7 +634,7 @@ trait Typers requires Analyzer {
}
}
}
-// System.out.println("adapt "+tree+":"+tree.tpe+", mode = "+mode+", pt = "+pt)
+// Console.println("adapt "+tree+":"+tree.tpe+", mode = "+mode+", pt = "+pt)
// adapt(tree, mode, pt)
// }
@@ -709,7 +710,7 @@ trait Typers requires Analyzer {
}
}
}
- //System.out.println("parents("+context.owner+") = "+supertpt :: mixins);//DEBUG
+ //Console.println("parents("+context.owner+") = "+supertpt :: mixins);//DEBUG
List.mapConserve(supertpt :: mixins)(tpt => checkNoEscaping.privates(context.owner, tpt))
}
} catch {
@@ -754,9 +755,9 @@ trait Typers requires Analyzer {
context.unit.source.file != psym.sourceFile)
error(parent.pos, "illegal inheritance from sealed "+psym)
if (!(selfType <:< parent.tpe.typeOfThis) && !phase.erasedTypes) {
- //System.out.println(context.owner);//DEBUG
- //System.out.println(context.owner.unsafeTypeParams);//DEBUG
- //System.out.println(List.fromArray(context.owner.info.closure));//DEBUG
+ //Console.println(context.owner);//DEBUG
+ //Console.println(context.owner.unsafeTypeParams);//DEBUG
+ //Console.println(List.fromArray(context.owner.info.closure));//DEBUG
error(parent.pos, "illegal inheritance;\n self-type "+
selfType+" does not conform to "+parent +
"'s selftype "+parent.tpe.typeOfThis)
@@ -794,7 +795,7 @@ trait Typers requires Analyzer {
* @return ...
*/
def typedModuleDef(mdef: ModuleDef): Tree = {
- //System.out.println("sourcefile of " + mdef.symbol + "=" + mdef.symbol.sourceFile)
+ //Console.println("sourcefile of " + mdef.symbol + "=" + mdef.symbol.sourceFile)
attributes(mdef)
val clazz = mdef.symbol.moduleClass
val impl1 = newTyper(context.make(mdef.impl, clazz, newTemplateScope(mdef.impl, clazz)))
@@ -916,7 +917,7 @@ trait Typers requires Analyzer {
if (!superClazz.hasFlag(JAVA)) {
val superParamAccessors = superClazz.constrParamAccessors
if (superParamAccessors.length != superArgs.length) {
- System.out.println("" + superClazz + ":" +
+ Console.println("" + superClazz + ":" +
superClazz.info.decls.toList.filter(.hasFlag(PARAMACCESSOR)))
assert(false, "mismatch: " + superParamAccessors +
";" + rhs + ";" + superClazz.info.decls)//debug
@@ -1245,7 +1246,7 @@ trait Typers requires Analyzer {
case MethodType(formals0, restpe) =>
val formals = formalTypes(formals0, args.length)
if (formals.length != args.length) {
- //System.out.println(""+formals.length+" "+args.length);//DEBUG
+ //Console.println(""+formals.length+" "+args.length);//DEBUG
errorTree(tree, "wrong number of arguments for "+treeSymTypeMsg(fun))
} else {
val tparams = context.undetparams
@@ -1555,7 +1556,7 @@ trait Typers requires Analyzer {
if (qual1 ne qual) return typed(copy.Select(tree, qual1, name), mode, pt)
}
if (!sym.exists) {
- if (settings.debug.value) System.err.println("qual = "+qual+":"+qual.tpe+"\nSymbol="+qual.tpe.symbol+"\nsymbol-info = "+qual.tpe.symbol.info+"\nscope-id = "+qual.tpe.symbol.info.decls.hashCode()+"\nmembers = "+qual.tpe.members+"\nname = "+name+"\nfound = "+sym+"\nowner = "+context.enclClass.owner)
+ if (settings.debug.value) Console.err.println("qual = "+qual+":"+qual.tpe+"\nSymbol="+qual.tpe.symbol+"\nsymbol-info = "+qual.tpe.symbol.info+"\nscope-id = "+qual.tpe.symbol.info.decls.hashCode()+"\nmembers = "+qual.tpe.members+"\nname = "+name+"\nfound = "+sym+"\nowner = "+context.enclClass.owner)
if (!qual.tpe.widen.isErroneous) {
if (false && context.unit == null) assert(false, "("+qual+":"+qual.tpe+")."+name)
error(tree.pos,
@@ -1978,7 +1979,7 @@ trait Typers requires Analyzer {
else {
val ps = clazz.info.parents filter (p => p.symbol.name == mix)
if (ps.isEmpty) {
- if (settings.debug.value) System.out.println(clazz.info.parents map (.symbol.name));//debug
+ if (settings.debug.value) Console.println(clazz.info.parents map (.symbol.name));//debug
error(tree.pos, ""+mix+" does not name a parent class of "+clazz)
ErrorType
} else if (ps.tail.isEmpty) {
@@ -2065,8 +2066,8 @@ trait Typers requires Analyzer {
} else if (tparams.length == 0) {
errorTree(tree, ""+tpt1.tpe+" does not take type parameters")
} else {
- //System.out.println("\{tpt1}:\{tpt1.symbol}:\{tpt1.symbol.info}")
- if (settings.debug.value) System.out.println(""+tpt1+":"+tpt1.symbol+":"+tpt1.symbol.info);//debug
+ //Console.println("\{tpt1}:\{tpt1.symbol}:\{tpt1.symbol.info}")
+ if (settings.debug.value) Console.println(""+tpt1+":"+tpt1.symbol+":"+tpt1.symbol.info);//debug
errorTree(tree, "wrong number of type arguments for "+tpt1.tpe+", should be "+tparams.length)
}
@@ -2098,21 +2099,21 @@ trait Typers requires Analyzer {
val ret = typedHookForType(tree, mode, pt);
if (ret != null) return ret;
}
- //System.out.println("typing "+tree+", "+context.undetparams);//DEBUG
+ //Console.println("typing "+tree+", "+context.undetparams);//DEBUG
val tree1 = if (tree.tpe != null) tree else typed1(tree, mode, pt)
- //System.out.println("typed "+tree1+":"+tree1.tpe+", "+context.undetparams);//DEBUG
+ //Console.println("typed "+tree1+":"+tree1.tpe+", "+context.undetparams);//DEBUG
val result = if (tree1.isEmpty) tree1 else adapt(tree1, mode, pt)
- //System.out.println("adapted "+tree1+":"+tree1.tpe+" to "+pt+", "+context.undetparams);//DEBUG
+ //Console.println("adapted "+tree1+":"+tree1.tpe+" to "+pt+", "+context.undetparams);//DEBUG
result
} catch {
case ex: TypeError =>
tree.tpe = null
- //System.out.println("caught "+ex+" in typed");//DEBUG
+ //Console.println("caught "+ex+" in typed");//DEBUG
reportTypeError(tree.pos, ex)
setError(tree)
case ex: Throwable =>
if (settings.debug.value)
- System.out.println("exception when typing "+tree+", pt = "+pt)
+ Console.println("exception when typing "+tree+", pt = "+pt)
if (context != null && context.unit != null &&
context.unit.source != null && tree != null)
logError("AT: " + context.unit.source.dbg(tree.pos), ex);
@@ -2261,7 +2262,7 @@ trait Typers requires Analyzer {
private def inferImplicit(pos: PositionType, pt: Type, isView: boolean, reportAmbiguous: boolean): Tree = {
if (util.Statistics.enabled) implcnt = implcnt + 1
- val startTime = if (util.Statistics.enabled) System.currentTimeMillis() else 0l
+ val startTime = if (util.Statistics.enabled) currentTime else 0l
val tc = newTyper(context.makeImplicit(reportAmbiguous))
@@ -2349,7 +2350,7 @@ trait Typers requires Analyzer {
var tree = searchImplicit(context.implicitss, true)
if (tree == EmptyTree) tree = searchImplicit(implicitsOfType(pt), false)
if (util.Statistics.enabled)
- impltime = impltime + System.currentTimeMillis() - startTime
+ impltime = impltime + currentTime - startTime
tree
}
diff --git a/src/compiler/scala/tools/nsc/util/ClassPath.scala b/src/compiler/scala/tools/nsc/util/ClassPath.scala
index 0256db87a7..a2ec9d945b 100644
--- a/src/compiler/scala/tools/nsc/util/ClassPath.scala
+++ b/src/compiler/scala/tools/nsc/util/ClassPath.scala
@@ -81,7 +81,7 @@ class ClassPath(onlyPresentation: Boolean) {
else new Source(source0, head.source.compile)
}
try {
- //System.err.println("this=" + this + "\nclazz=" + clazz + "\nsource0=" + source0 + "\n")
+ //Console.err.println("this=" + this + "\nclazz=" + clazz + "\nsource0=" + source0 + "\n")
new Context(entry :: ret.entries)
} catch {
case e: Error =>
@@ -93,7 +93,7 @@ class ClassPath(onlyPresentation: Boolean) {
val ret = find0(entries)
if (ret.entries.isEmpty) {
- //System.err.println("BAD_FILE: " + name + " in " + this)
+ //Console.err.println("BAD_FILE: " + name + " in " + this)
null
} else ret
} else null
@@ -150,7 +150,7 @@ class ClassPath(onlyPresentation: Boolean) {
val sourcePath0 = sourcePath
if (sourcePath0 != null) {
if (!sourcePath0.isDirectory) {
- System.err.println(""+sourcePath0 + " cannot be a directory")
+ Console.err.println(""+sourcePath0 + " cannot be a directory")
assert(false)
}
}
@@ -184,7 +184,7 @@ class ClassPath(onlyPresentation: Boolean) {
addArchivesInExtDirPath(extdirs)
val clazzes = AbstractFile.getDirectory(output)
if (clazzes == null) {
- System.err.println("Output location \"" + output + "\" not found")
+ Console.err.println("Output location \"" + output + "\" not found")
exit(1)
}
val strtok = new StringTokenizer(source, File.pathSeparator)
diff --git a/src/compiler/scala/tools/nsc/util/HashSet.scala b/src/compiler/scala/tools/nsc/util/HashSet.scala
index 5aa79dd141..2b2b8bdc53 100644
--- a/src/compiler/scala/tools/nsc/util/HashSet.scala
+++ b/src/compiler/scala/tools/nsc/util/HashSet.scala
@@ -12,7 +12,7 @@ class HashSet[T >: Null <: AnyRef](initialCapacity: int) extends Set[T] {
private var capacity = initialCapacity
private var used = 0
- private var table = new Array[Object](capacity)
+ private var table = new Array[AnyRef](capacity)
def size: int = used
@@ -53,7 +53,7 @@ class HashSet[T >: Null <: AnyRef](initialCapacity: int) extends Set[T] {
private def growTable: unit = {
val oldtable = table
capacity = capacity * 2
- table = new Array[Object](capacity)
+ table = new Array[AnyRef](capacity)
var i = 0
while (i < oldtable.length) {
val entry = oldtable(i)
diff --git a/src/compiler/scala/tools/nsc/util/NameTransformer.scala b/src/compiler/scala/tools/nsc/util/NameTransformer.scala
index 0df9508657..54c444f118 100644
--- a/src/compiler/scala/tools/nsc/util/NameTransformer.scala
+++ b/src/compiler/scala/tools/nsc/util/NameTransformer.scala
@@ -6,6 +6,8 @@
package scala.tools.nsc.util
+import compat.StringBuilder
+
object NameTransformer {
private val nops = 128
private val ncodes = 26 * 26
@@ -46,14 +48,14 @@ object NameTransformer {
* @return ...
*/
def encode(name: String): String = {
- var buf: StringBuffer = null
+ var buf: StringBuilder = null
val len = name.length()
var i = 0
while (i < len) {
val c = name charAt i
if (c < nops && op2code(c) != null) {
if (buf == null) {
- buf = new StringBuffer()
+ buf = new StringBuilder()
buf.append(name.substring(0, i))
}
buf.append(op2code(c))
@@ -74,7 +76,7 @@ object NameTransformer {
//System.out.println("decode: " + name);//DEBUG
val name = if (name0.endsWith("<init>")) name0.substring(0, name0.length() - ("<init>").length()) + "this"
else name0;
- var buf: StringBuffer = null
+ var buf: StringBuilder = null
val len = name.length()
var i = 0
while (i < len) {
@@ -89,7 +91,7 @@ object NameTransformer {
while (ops != null && !name.startsWith(ops.code, i)) ops = ops.next;
if (ops != null) {
if (buf == null) {
- buf = new StringBuffer()
+ buf = new StringBuilder()
buf.append(name.substring(0, i))
}
buf.append(ops.op)
diff --git a/src/compiler/scala/tools/nsc/util/Position.scala b/src/compiler/scala/tools/nsc/util/Position.scala
index 7d26dbc6d4..a7bd8f211e 100644
--- a/src/compiler/scala/tools/nsc/util/Position.scala
+++ b/src/compiler/scala/tools/nsc/util/Position.scala
@@ -11,6 +11,9 @@
package scala.tools.nsc.util
+
+import compat.StringBuilder
+
/** This position uses offset in character buffer rather than line/column
* relationship.
*
@@ -98,7 +101,7 @@ class Position( val source : SourceFile, val offset: Int) {
if(inUltimateSource != this)
return inUltimateSource.toString
- val sb = new StringBuffer()
+ val sb = new StringBuilder()
if (source != null) {
sb.append(source.file.path)
if (hasOffset) {
diff --git a/src/compiler/scala/tools/nsc/util/ShowPickled.scala b/src/compiler/scala/tools/nsc/util/ShowPickled.scala
index c526ec79e4..115aa4eb9d 100644
--- a/src/compiler/scala/tools/nsc/util/ShowPickled.scala
+++ b/src/compiler/scala/tools/nsc/util/ShowPickled.scala
@@ -6,7 +6,10 @@
package scala.tools.nsc.util
-import java.io._
+import java.lang.Integer.toHexString
+import java.lang.Float.intBitsToFloat
+import java.lang.Double.longBitsToDouble
+import java.io.{File, FileInputStream, PrintStream, IOException}
import symtab.{Flags, Names}
import symtab.classfile.{PickleBuffer, PickleFormat}
@@ -75,7 +78,7 @@ object ShowPickled extends Names {
printNameRef()
printSymbolRef()
val flags = buf.readNat()
- out.print(" " + Integer.toHexString(flags) +
+ out.print(" " + toHexString(flags) +
"[" + Flags.flagsToString(flags) + "] ")
printTypeRef()
}
@@ -134,9 +137,9 @@ object ShowPickled extends Names {
case LITERALlong =>
out.print(" " + buf.readLong(len))
case LITERALfloat =>
- out.print(" " + Float.intBitsToFloat(buf.readLong(len).asInstanceOf[int]))
+ out.print(" " + intBitsToFloat(buf.readLong(len).asInstanceOf[int]))
case LITERALdouble =>
- out.print(" " + Double.longBitsToDouble(buf.readLong(len)))
+ out.print(" " + longBitsToDouble(buf.readLong(len)))
case LITERALstring =>
printNameRef()
case LITERALnull =>
@@ -160,10 +163,10 @@ object ShowPickled extends Names {
val data = new Array[byte](stream.available())
stream.read(data)
val pickle = new PickleBuffer(data, 0, data.length)
- printFile(pickle, System.out)
+ printFile(pickle, Console.out)
} catch {
case ex: IOException =>
- System.out.println("cannot read " + file + ": " + ex.getMessage())
+ Console.println("cannot read " + file + ": " + ex.getMessage())
}
}
}
diff --git a/src/compiler/scala/tools/nsc/util/SourceFile.scala b/src/compiler/scala/tools/nsc/util/SourceFile.scala
index 19ae7bc849..c72e1899e7 100644
--- a/src/compiler/scala/tools/nsc/util/SourceFile.scala
+++ b/src/compiler/scala/tools/nsc/util/SourceFile.scala
@@ -11,6 +11,7 @@
package scala.tools.nsc.util
+import compat.StringBuilder
import scala.tools.nsc.io.{AbstractFile, VirtualFile}
/** Uses positions that are offsets rather than line/column pairs.
@@ -121,12 +122,12 @@ class SourceFile(val file: AbstractFile, _content: Array[Char]) {
def path = getFile().path
def skipWhitespace(offset: Int): Int =
- if (Character.isWhitespace(content(offset))) skipWhitespace(offset + 1)
+ if (content(offset).isWhitespace) skipWhitespace(offset + 1)
else offset
def lineToString(index: Int): String = {
var offset = lineToOffset(index)
- val buf = new StringBuffer()
+ val buf = new StringBuilder()
while (!isLineBreak(offset) && offset < content.length) {
buf.append(content(offset))
offset = offset + 1
@@ -138,7 +139,7 @@ class SourceFile(val file: AbstractFile, _content: Array[Char]) {
if (input.length > 0 && input(input.length - 1) == SU) input
else {
val content = new Array[char](input.length + 1)
- System.arraycopy(input, 0, content, 0, input.length)
+ Array.copy(input, 0, content, 0, input.length)
content(input.length) = SU
content
}