summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-12-05 02:56:08 +0000
committerPaul Phillips <paulp@improving.org>2010-12-05 02:56:08 +0000
commit77eb8fefec3e62ead95c7d409ec5a28f30289ec3 (patch)
tree5e035714a7e6363d1ae7f712d5b1f73c1d27d79e /src/compiler
parent626e38940b72f5e8445ecbece4d41996b5e2842e (diff)
downloadscala-77eb8fefec3e62ead95c7d409ec5a28f30289ec3.tar.gz
scala-77eb8fefec3e62ead95c7d409ec5a28f30289ec3.tar.bz2
scala-77eb8fefec3e62ead95c7d409ec5a28f30289ec3.zip
Mopping up after the deprecation of exit and er...
Mopping up after the deprecation of exit and error. It is decidedly non-trivial (at least for the IDE-impaired) to be completely sure of which error function was being called when there were about twenty with the same signature in trunk and they are being variously inherited, imported, shadowed, etc. So although I was careful, the possibility exists that something is now calling a different "error" function than before. Caveat programmer. (And let's all make it our policy not to name anything "error" or "exit" from here on out....) No review.
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/ant/FastScalac.scala6
-rw-r--r--src/compiler/scala/tools/ant/Pack200Task.scala20
-rw-r--r--src/compiler/scala/tools/ant/Same.scala9
-rw-r--r--src/compiler/scala/tools/ant/ScalaBazaar.scala27
-rw-r--r--src/compiler/scala/tools/ant/ScalaMatchingTask.scala31
-rw-r--r--src/compiler/scala/tools/ant/ScalaTool.scala21
-rw-r--r--src/compiler/scala/tools/ant/Scalac.scala42
-rw-r--r--src/compiler/scala/tools/ant/ScalacShared.scala4
-rw-r--r--src/compiler/scala/tools/ant/Scaladoc.scala42
-rw-r--r--src/compiler/scala/tools/ant/sabbus/Break.scala2
-rw-r--r--src/compiler/scala/tools/ant/sabbus/Make.scala4
-rw-r--r--src/compiler/scala/tools/ant/sabbus/ScalacFork.scala12
-rw-r--r--src/compiler/scala/tools/ant/sabbus/Use.scala14
-rw-r--r--src/compiler/scala/tools/cmd/Demo.scala2
-rw-r--r--src/compiler/scala/tools/cmd/package.scala3
-rw-r--r--src/compiler/scala/tools/cmd/program/Simple.scala4
-rw-r--r--src/compiler/scala/tools/nsc/CompileClient.scala2
-rw-r--r--src/compiler/scala/tools/nsc/CompileServer.scala9
-rw-r--r--src/compiler/scala/tools/nsc/CompileSocket.scala6
-rw-r--r--src/compiler/scala/tools/nsc/Global.scala27
-rw-r--r--src/compiler/scala/tools/nsc/Interpreter.scala2
-rw-r--r--src/compiler/scala/tools/nsc/InterpreterLoop.scala8
-rw-r--r--src/compiler/scala/tools/nsc/Main.scala8
-rw-r--r--src/compiler/scala/tools/nsc/MainGenericRunner.scala2
-rw-r--r--src/compiler/scala/tools/nsc/MainTokenMetric.scala4
-rw-r--r--src/compiler/scala/tools/nsc/PhaseAssembly.scala6
-rw-r--r--src/compiler/scala/tools/nsc/ScalaDoc.scala7
-rw-r--r--src/compiler/scala/tools/nsc/ScriptRunner.scala4
-rw-r--r--src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala2
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/ExceptionHandlers.scala4
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/GenICode.scala2
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala47
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/Linearizers.scala4
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala2
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala2
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/analysis/DataFlowAnalysis.scala2
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala2
-rw-r--r--src/compiler/scala/tools/nsc/backend/opt/Inliners.scala2
-rw-r--r--src/compiler/scala/tools/nsc/interactive/BuildManager.scala4
-rw-r--r--src/compiler/scala/tools/nsc/interactive/REPL.scala8
-rw-r--r--src/compiler/scala/tools/nsc/interactive/RangePositions.scala10
-rw-r--r--src/compiler/scala/tools/nsc/interactive/tests/Tester.scala2
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/InteractiveReader.scala2
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/ReflectionCompletion.scala4
-rw-r--r--src/compiler/scala/tools/nsc/io/VirtualDirectory.scala4
-rw-r--r--src/compiler/scala/tools/nsc/plugins/Plugins.scala6
-rw-r--r--src/compiler/scala/tools/nsc/settings/AbsScalaSettings.scala2
-rw-r--r--src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala2
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala26
-rw-r--r--src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala2
-rw-r--r--src/compiler/scala/tools/nsc/transform/UnCurry.scala2
-rw-r--r--src/compiler/scala/tools/nsc/util/MsilClassPath.scala2
-rw-r--r--src/compiler/scala/tools/nsc/util/ShowPickled.scala4
-rw-r--r--src/compiler/scala/tools/reflect/Mock.scala2
-rw-r--r--src/compiler/scala/tools/util/SocketServer.scala2
55 files changed, 235 insertions, 246 deletions
diff --git a/src/compiler/scala/tools/ant/FastScalac.scala b/src/compiler/scala/tools/ant/FastScalac.scala
index 8c8363a321..98e6098f89 100644
--- a/src/compiler/scala/tools/ant/FastScalac.scala
+++ b/src/compiler/scala/tools/ant/FastScalac.scala
@@ -99,16 +99,16 @@ class FastScalac extends Scalac {
val args = (cmdOptions ::: (sourceFiles map (_.toString))).toArray
try {
if (scala.tools.nsc.CompileClient.main0(args) > 0 && failonerror)
- error("Compile failed; see the compiler error output for details.")
+ buildError("Compile failed; see the compiler error output for details.")
}
catch {
case exception: Throwable if (exception.getMessage ne null) =>
exception.printStackTrace()
- error("Compile failed because of an internal compiler error (" +
+ buildError("Compile failed because of an internal compiler error (" +
exception.getMessage + "); see the error output for details.")
case exception =>
exception.printStackTrace()
- error("Compile failed because of an internal compiler error " +
+ buildError("Compile failed because of an internal compiler error " +
"(no error message provided); see the error output for details.")
}
}
diff --git a/src/compiler/scala/tools/ant/Pack200Task.scala b/src/compiler/scala/tools/ant/Pack200Task.scala
index 12a8706a1c..c15e1f04f5 100644
--- a/src/compiler/scala/tools/ant/Pack200Task.scala
+++ b/src/compiler/scala/tools/ant/Pack200Task.scala
@@ -16,7 +16,6 @@ import java.util.jar.{JarFile, JarInputStream, JarOutputStream, Pack200}
import java.util.jar.Pack200.Packer._
import org.apache.tools.ant.{BuildException, DirectoryScanner}
-import org.apache.tools.ant.taskdefs.MatchingTask
import org.apache.tools.ant.types.FileSet
/** <p>
@@ -34,7 +33,7 @@ import org.apache.tools.ant.types.FileSet
*
* @author James Matlik
*/
-class Pack200Task extends MatchingTask {
+class Pack200Task extends ScalaMatchingTask {
/*============================================================================*\
** Ant user-properties **
@@ -58,13 +57,13 @@ class Pack200Task extends MatchingTask {
def setDir(dir: File) {
if (dir.exists && dir.isDirectory) srcdir = Some(dir)
- else error("Please specify a valid directory with Jar files for packing.")
+ else buildError("Please specify a valid directory with Jar files for packing.")
}
/** A level from 0 (none) to 9 (max) of effort for applying Pack200 */
def setEffort(x: Int) {
if (effort < 10 && effort > -1) effort = x
- else error("The effort level must be a value from 0 to 9")
+ else buildError("The effort level must be a value from 0 to 9")
}
/** Set the flag to specify if file reordering should be performed. Reordering
@@ -89,7 +88,7 @@ class Pack200Task extends MatchingTask {
/** Set the output directory */
def setDestdir(file: File) {
if (file != null && file.exists && file.isDirectory) destdir = Some(file)
- else error("The destination directory is invalid: " + file.getAbsolutePath)
+ else buildError("The destination directory is invalid: " + file.getAbsolutePath)
}
def setSuffix(s: String) { packFileSuffix = s }
@@ -117,13 +116,6 @@ class Pack200Task extends MatchingTask {
** Compilation and support methods **
\*============================================================================*/
-/** Generates a build error. Error location will be the current task in the
- * ant file.
- * @param message A message describing the error.
- * @throws BuildException A build error exception thrown in every case. */
- private def error(message: String): Nothing =
- throw new BuildException(message, getLocation())
-
private def makeJarOutputStream(file: File) =
new JarOutputStream(makeOutputStream(file))
@@ -137,13 +129,13 @@ class Pack200Task extends MatchingTask {
/** Performs the tool creation. */
override def execute() = {
// Audits
- val packDir = destdir.getOrElse(error("No output directory specified"))
+ val packDir = destdir.getOrElse(buildError("No output directory specified"))
// Setup the inherited fileset for further processing
fileset.setDir(srcdir.getOrElse(getProject.getBaseDir))
val files = getFileList
- if (files.isEmpty) error("No JAR files were selected for packing.")
+ if (files.isEmpty) buildError("No JAR files were selected for packing.")
// Setup the packer
val packer = Pack200.newPacker
diff --git a/src/compiler/scala/tools/ant/Same.scala b/src/compiler/scala/tools/ant/Same.scala
index 2ed0395cfa..2c68e12ba8 100644
--- a/src/compiler/scala/tools/ant/Same.scala
+++ b/src/compiler/scala/tools/ant/Same.scala
@@ -12,7 +12,6 @@ package scala.tools.ant
import java.io.{File, FileInputStream}
import org.apache.tools.ant.{BuildException, Project}
-import org.apache.tools.ant.taskdefs.MatchingTask
import org.apache.tools.ant.util.{FileNameMapper, IdentityMapper}
import org.apache.tools.ant.types.Mapper
@@ -32,7 +31,7 @@ import org.apache.tools.ant.types.Mapper
*
* @author Gilles Dubochet
* @version 1.0 */
-class Same extends MatchingTask {
+class Same extends ScalaMatchingTask {
/*============================================================================*\
** Ant user-properties **
\*============================================================================*/
@@ -91,8 +90,8 @@ class Same extends MatchingTask {
/** Tests if all mandatory attributes are set and valid. */
private def validateAttributes = {
- if (origin.isEmpty) error("Mandatory attribute 'dir' is not set.")
- if (destination.isEmpty) error("Mandatory attribute 'todir' is not set.")
+ if (origin.isEmpty) system.error("Mandatory attribute 'dir' is not set.")
+ if (destination.isEmpty) system.error("Mandatory attribute 'todir' is not set.")
}
private def reportDiff(f1: File, f2: File) = {
@@ -151,7 +150,7 @@ class Same extends MatchingTask {
}
if (!allEqualNow)
if (failing)
- error("There were differences between '" + origin.get + "' and '" + destination.get + "'")
+ system.error("There were differences between '" + origin.get + "' and '" + destination.get + "'")
else
log("There were differences between '" + origin.get + "' and '" + destination.get + "'")
else {
diff --git a/src/compiler/scala/tools/ant/ScalaBazaar.scala b/src/compiler/scala/tools/ant/ScalaBazaar.scala
index 1c1b0ccb46..f35ebc44d5 100644
--- a/src/compiler/scala/tools/ant/ScalaBazaar.scala
+++ b/src/compiler/scala/tools/ant/ScalaBazaar.scala
@@ -52,7 +52,7 @@ package scala.tools.ant {
* </ul>
*
* @author Gilles Dubochet */
- class ScalaBazaar extends Task {
+ class ScalaBazaar extends Task with ScalaTask {
/** The unique Ant file utilities instance to use in this task. */
private val fileUtils = FileUtils.getFileUtils()
@@ -161,10 +161,10 @@ package scala.tools.ant {
def addConfiguredLooseset(set: LooseFileSet) = {
Pair(set.destination, set.fileset) match {
case Pair(None, _) =>
- error("destination not specified for a loose file set")
+ buildError("destination not specified for a loose file set")
case Pair(_, None) =>
- error("no files specified for a loose file set")
+ buildError("no files specified for a loose file set")
case Pair(Some(dest), Some(fileset)) =>
fileSetsMap.update(dest, fileset)
@@ -178,19 +178,19 @@ package scala.tools.ant {
/** Gets the value of the file attribute in a Scala-friendly form.
* @return The file as a file. */
private def getName: String =
- if (name.isEmpty) error("Name attribute must be defined first.")
+ if (name.isEmpty) buildError("Name attribute must be defined first.")
else name.get
/** Gets the value of the file attribute in a Scala-friendly form.
* @return The file as a file. */
private def getFile: File =
- if (file.isEmpty) error("Member 'file' is empty.")
+ if (file.isEmpty) buildError("Member 'file' is empty.")
else getProject().resolveFile(file.get.toString())
/** Gets the value of the adfile attribute in a Scala-friendly form.
* @return The adfile as a file. */
private def getAdfile: File =
- if (adfile.isEmpty) error("Member 'adfile' is empty.")
+ if (adfile.isEmpty) buildError("Member 'adfile' is empty.")
else getProject().resolveFile(adfile.get.toString())
/******************************************************************************\
@@ -223,16 +223,9 @@ package scala.tools.ant {
file
}
- /** Generates a build error. Error location will be the current task in the
- * ant file.
- * @param message A message describing the error.
- * @throws BuildException A build error exception thrown in every case. */
- private def error(message: String): Nothing =
- throw new BuildException(message, getLocation())
-
private def writeFile(file: File, content: String) =
if (file.exists() && !file.canWrite())
- error("File " + file + " is not writable")
+ buildError("File " + file + " is not writable")
else {
val writer = new FileWriter(file, false)
writer.write(content)
@@ -246,9 +239,9 @@ package scala.tools.ant {
/** Performs the compilation. */
override def execute() = {
// Tests if all mandatory attributes are set and valid.
- if (file.isEmpty) error("Attribute 'file' is not set.")
- if (name.isEmpty) error("Attribute 'name' is not set.")
- if (version.isEmpty) error("Attribute 'version' is not set.")
+ if (file.isEmpty) buildError("Attribute 'file' is not set.")
+ if (name.isEmpty) buildError("Attribute 'name' is not set.")
+ if (version.isEmpty) buildError("Attribute 'version' is not set.")
val pack = {
<package>
diff --git a/src/compiler/scala/tools/ant/ScalaMatchingTask.scala b/src/compiler/scala/tools/ant/ScalaMatchingTask.scala
new file mode 100644
index 0000000000..5d065eb840
--- /dev/null
+++ b/src/compiler/scala/tools/ant/ScalaMatchingTask.scala
@@ -0,0 +1,31 @@
+/* __ *\
+** ________ ___ / / ___ Scala Ant Tasks **
+** / __/ __// _ | / / / _ | (c) 2005-2010, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+package scala.tools.ant
+
+import java.io.{ File, InputStream, FileWriter }
+
+import org.apache.tools.ant.{ Task, BuildException }
+import org.apache.tools.ant.taskdefs.MatchingTask
+import org.apache.tools.ant.types.{ Path, Reference }
+
+trait ScalaTask {
+ self: Task =>
+
+ /** Generates a build error. Error location will be the
+ * current task in the ant file.
+ *
+ * @param message A message describing the error.
+ * @throws BuildException A build error exception thrown in every case.
+ */
+ protected def buildError(message: String): Nothing =
+ throw new BuildException(message, getLocation())
+}
+
+abstract class ScalaMatchingTask extends MatchingTask with ScalaTask {
+}
diff --git a/src/compiler/scala/tools/ant/ScalaTool.scala b/src/compiler/scala/tools/ant/ScalaTool.scala
index db53224b4f..e9bc4435e1 100644
--- a/src/compiler/scala/tools/ant/ScalaTool.scala
+++ b/src/compiler/scala/tools/ant/ScalaTool.scala
@@ -10,9 +10,7 @@
package scala.tools.ant
import java.io.{File, InputStream, FileWriter}
-
import org.apache.tools.ant.BuildException
-import org.apache.tools.ant.taskdefs.MatchingTask
import org.apache.tools.ant.types.{Path, Reference}
/** <p>
@@ -31,7 +29,7 @@ import org.apache.tools.ant.types.{Path, Reference}
* @author Gilles Dubochet
* @version 1.1
*/
-class ScalaTool extends MatchingTask {
+class ScalaTool extends ScalaMatchingTask {
private def emptyPath = new Path(getProject)
@@ -101,7 +99,7 @@ class ScalaTool extends MatchingTask {
if (Platforms.isPermissible(st))
(if (input != "") List(st) else Nil)
else {
- error("Platform " + st + " does not exist.")
+ buildError("Platform " + st + " does not exist.")
Nil
}
}
@@ -148,7 +146,7 @@ class ScalaTool extends MatchingTask {
if (input != "") List(Pair(stArray(0), stArray(1))) else Nil
}
else
- error("Property " + st + " is not formatted properly.")
+ buildError("Property " + st + " is not formatted properly.")
}
}
@@ -183,13 +181,6 @@ class ScalaTool extends MatchingTask {
** Compilation and support methods **
\*============================================================================*/
- /** Generates a build error. Error location will be the current task in the
- * ant file.
- * @param message A message describing the error.
- * @throws BuildException A build error exception thrown in every case. */
- private def error(message: String): Nothing =
- throw new BuildException(message, getLocation())
-
// XXX encoding and generalize
private def getResourceAsCharStream(clazz: Class[_], resource: String): Stream[Char] = {
val stream = clazz.getClassLoader() getResourceAsStream resource
@@ -246,7 +237,7 @@ class ScalaTool extends MatchingTask {
private def writeFile(file: File, content: String) =
if (file.exists() && !file.canWrite())
- error("File " + file + " is not writable")
+ buildError("File " + file + " is not writable")
else {
val writer = new FileWriter(file, false)
writer.write(content)
@@ -260,8 +251,8 @@ class ScalaTool extends MatchingTask {
/** Performs the tool creation. */
override def execute() = {
// Tests if all mandatory attributes are set and valid.
- if (file.isEmpty) error("Attribute 'file' is not set.")
- if (mainClass.isEmpty) error("Main class must be set.")
+ if (file.isEmpty) buildError("Attribute 'file' is not set.")
+ if (mainClass.isEmpty) buildError("Main class must be set.")
val resourceRoot = "scala/tools/ant/templates/"
val patches = Map (
("class", mainClass.get),
diff --git a/src/compiler/scala/tools/ant/Scalac.scala b/src/compiler/scala/tools/ant/Scalac.scala
index 20ed9fc6d4..6c56ace9fe 100644
--- a/src/compiler/scala/tools/ant/Scalac.scala
+++ b/src/compiler/scala/tools/ant/Scalac.scala
@@ -12,7 +12,7 @@ package scala.tools.ant
import java.io.{File,PrintWriter,BufferedWriter,FileWriter}
import org.apache.tools.ant.{ BuildException, Project, AntClassLoader }
-import org.apache.tools.ant.taskdefs.{MatchingTask,Java}
+import org.apache.tools.ant.taskdefs.Java
import org.apache.tools.ant.types.{Path, Reference}
import org.apache.tools.ant.util.{FileUtils, GlobPatternMapper,
SourceFileScanner}
@@ -68,7 +68,7 @@ import scala.tools.nsc.reporters.{Reporter, ConsoleReporter}
*
* @author Gilles Dubochet, Stephane Micheloud
*/
-class Scalac extends MatchingTask with ScalacShared {
+class Scalac extends ScalaMatchingTask with ScalacShared {
/** The unique Ant file utilities instance to use in this task. */
private val fileUtils = FileUtils.getFileUtils()
@@ -173,7 +173,7 @@ class Scalac extends MatchingTask with ScalacShared {
case None => Some(arg)
}
private def pathAsList(p: Option[Path], name: String): List[File] = p match {
- case None => error("Member '" + name + "' is empty.")
+ case None => buildError("Member '" + name + "' is empty.")
case Some(x) => x.list.toList map nameToFile
}
private def createNewPath(getter: () => Option[Path], setter: (Option[Path]) => Unit) = {
@@ -296,7 +296,7 @@ class Scalac extends MatchingTask with ScalacShared {
* @param input The value for <code>target</code>. */
def setTarget(input: String): Unit =
if (Target.isPermissible(input)) backend = Some(input)
- else error("Unknown target '" + input + "'")
+ else buildError("Unknown target '" + input + "'")
/** Sets the <code>force</code> attribute. Used by Ant.
* @param input The value for <code>force</code>. */
@@ -317,7 +317,7 @@ class Scalac extends MatchingTask with ScalacShared {
* @param input The value for <code>logging</code>. */
def setLogging(input: String) {
if (LoggingLevel.isPermissible(input)) logging = Some(input)
- else error("Logging level '" + input + "' does not exist.")
+ else buildError("Logging level '" + input + "' does not exist.")
}
/** Sets the <code>logphase</code> attribute. Used by Ant.
@@ -328,7 +328,7 @@ class Scalac extends MatchingTask with ScalacShared {
if (CompilerPhase.isPermissible(st))
(if (input != "") List(st) else Nil)
else {
- error("Phase " + st + " in log does not exist.")
+ buildError("Phase " + st + " in log does not exist.")
Nil
}
}
@@ -345,19 +345,19 @@ class Scalac extends MatchingTask with ScalacShared {
/** Set the <code>deprecation</code> info attribute.
* @param input One of the flags <code>yes/no</code> or <code>on/off</code>. */
def setDeprecation(input: String) {
- deprecation = Flag toBoolean input orElse error("Unknown deprecation flag '" + input + "'")
+ deprecation = Flag toBoolean input orElse buildError("Unknown deprecation flag '" + input + "'")
}
/** Set the <code>optimise</code> info attribute.
* @param input One of the flags <code>yes/no</code> or <code>on/off</code>. */
def setOptimise(input: String) {
- optimise = Flag toBoolean input orElse error("Unknown optimisation flag '" + input + "'")
+ optimise = Flag toBoolean input orElse buildError("Unknown optimisation flag '" + input + "'")
}
/** Set the <code>unchecked</code> info attribute.
* @param input One of the flags <code>yes/no</code> or <code>on/off</code>. */
def setUnchecked(input: String) {
- unchecked = Flag toBoolean input orElse error("Unknown unchecked flag '" + input + "'")
+ unchecked = Flag toBoolean input orElse buildError("Unknown unchecked flag '" + input + "'")
}
/** Sets the <code>force</code> attribute. Used by Ant.
@@ -391,7 +391,7 @@ class Scalac extends MatchingTask with ScalacShared {
* Scala-friendly form.
* @return The destination as a file. */
protected def getDestination: File =
- if (destination.isEmpty) error("Member 'destination' is empty.")
+ if (destination.isEmpty) buildError("Member 'destination' is empty.")
else existing(getProject().resolveFile(destination.get.toString))
/** Gets the value of the <code>sourcepath</code> attribute in a
@@ -452,14 +452,6 @@ class Scalac extends MatchingTask with ScalacShared {
protected def asString(file: File): String =
file.getAbsolutePath()
- /** Generates a build error. Error location will be the current task in the
- * ant file.
- * @param message A message describing the error.
- * @throws BuildException A build error exception thrown in every case. */
- protected def error(message: String): Nothing =
- throw new BuildException(message, getLocation())
-
-
/*============================================================================*\
** Hooks for variants of Scala **
\*============================================================================*/
@@ -480,9 +472,9 @@ class Scalac extends MatchingTask with ScalacShared {
log("Base directory is `%s`".format(scala.tools.nsc.io.Path("").normalize))
// Tests if all mandatory attributes are set and valid.
- if (origin.isEmpty) error("Attribute 'srcdir' is not set.")
+ if (origin.isEmpty) buildError("Attribute 'srcdir' is not set.")
if (!destination.isEmpty && !destination.get.isDirectory())
- error("Attribute 'destdir' does not refer to an existing directory.")
+ buildError("Attribute 'destdir' does not refer to an existing directory.")
if (destination.isEmpty) destination = Some(getOrigin.head)
val mapper = new GlobPatternMapper()
@@ -531,7 +523,7 @@ class Scalac extends MatchingTask with ScalacShared {
// Builds-up the compilation settings for Scalac with the existing Ant
// parameters.
- val settings = newSettings(error)
+ val settings = newSettings(buildError)
settings.outdir.value = asString(destination.get)
if (!classpath.isEmpty)
settings.classpath.value = asString(getClasspath)
@@ -599,7 +591,7 @@ class Scalac extends MatchingTask with ScalacShared {
if (compilerPath.isDefined) path add compilerPath.get
else getClass.getClassLoader match {
case cl: AntClassLoader => path add new Path(getProject, cl.getClasspath)
- case _ => error("Cannot determine default classpath for scalac, please specify one!")
+ case _ => buildError("Cannot determine default classpath for scalac, please specify one!")
}
path
}
@@ -626,7 +618,7 @@ class Scalac extends MatchingTask with ScalacShared {
}
val res = execWithArgFiles(java, List(writeSettings.getCanonicalPath))
if (failonerror && res != 0)
- error("Compilation failed because of an internal compiler error;"+
+ buildError("Compilation failed because of an internal compiler error;"+
" see the error output for details.")
}
@@ -640,14 +632,14 @@ class Scalac extends MatchingTask with ScalacShared {
case ex: Throwable =>
ex.printStackTrace()
val msg = if (ex.getMessage == null) "no error message provided" else ex.getMessage
- error("Compile failed because of an internal compiler error (" + msg + "); see the error output for details.")
+ buildError("Compile failed because of an internal compiler error (" + msg + "); see the error output for details.")
}
reporter.printSummary()
if (reporter.hasErrors) {
val msg = "Compile failed with %d error%s; see the compiler error output for details.".format(
reporter.ERROR.count, plural(reporter.ERROR.count))
- if (failonerror) error(msg) else log(msg)
+ if (failonerror) buildError(msg) else log(msg)
}
else if (reporter.WARNING.count > 0)
log("Compile succeeded with %d warning%s; see the compiler output for details.".format(
diff --git a/src/compiler/scala/tools/ant/ScalacShared.scala b/src/compiler/scala/tools/ant/ScalacShared.scala
index 356fb99e56..f4cb444405 100644
--- a/src/compiler/scala/tools/ant/ScalacShared.scala
+++ b/src/compiler/scala/tools/ant/ScalacShared.scala
@@ -9,10 +9,10 @@
package scala.tools.ant
import org.apache.tools.ant.Project
-import org.apache.tools.ant.taskdefs.{ MatchingTask, Java }
+import org.apache.tools.ant.taskdefs.Java
import scala.tools.nsc.io
-trait ScalacShared extends MatchingTask {
+trait ScalacShared extends ScalaMatchingTask {
val MainClass = "scala.tools.nsc.Main"
def execWithArgFiles(java: Java, paths: List[String]) = {
diff --git a/src/compiler/scala/tools/ant/Scaladoc.scala b/src/compiler/scala/tools/ant/Scaladoc.scala
index 427846fa33..be5311b471 100644
--- a/src/compiler/scala/tools/ant/Scaladoc.scala
+++ b/src/compiler/scala/tools/ant/Scaladoc.scala
@@ -12,7 +12,6 @@ package scala.tools.ant
import java.io.File
import org.apache.tools.ant.{BuildException, Project}
-import org.apache.tools.ant.taskdefs.MatchingTask
import org.apache.tools.ant.types.{Path, Reference}
import org.apache.tools.ant.util.{FileUtils, GlobPatternMapper}
@@ -61,7 +60,7 @@ import scala.tools.nsc.reporters.{Reporter, ConsoleReporter}
*
* @author Gilles Dubochet, Stephane Micheloud
*/
-class Scaladoc extends MatchingTask {
+class Scaladoc extends ScalaMatchingTask {
/** The unique Ant file utilities instance to use in this task. */
private val fileUtils = FileUtils.getFileUtils()
@@ -306,7 +305,7 @@ class Scaladoc extends MatchingTask {
if (Flag.isPermissible(input))
deprecation = "yes".equals(input) || "on".equals(input)
else
- error("Unknown deprecation flag '" + input + "'")
+ buildError("Unknown deprecation flag '" + input + "'")
}
/** Set the <code>unchecked</code> info attribute.
@@ -317,7 +316,7 @@ class Scaladoc extends MatchingTask {
if (Flag.isPermissible(input))
unchecked = "yes".equals(input) || "on".equals(input)
else
- error("Unknown unchecked flag '" + input + "'")
+ buildError("Unknown unchecked flag '" + input + "'")
}
/*============================================================================*\
@@ -330,7 +329,7 @@ class Scaladoc extends MatchingTask {
* @return The class path as a list of files.
*/
private def getClasspath: List[File] =
- if (classpath.isEmpty) error("Member 'classpath' is empty.")
+ if (classpath.isEmpty) buildError("Member 'classpath' is empty.")
else classpath.get.list().toList.map(nameToFile)
/** Gets the value of the <code>origin</code> attribute in a Scala-friendly
@@ -339,7 +338,7 @@ class Scaladoc extends MatchingTask {
* @return The origin path as a list of files.
*/
private def getOrigin: List[File] =
- if (origin.isEmpty) error("Member 'origin' is empty.")
+ if (origin.isEmpty) buildError("Member 'origin' is empty.")
else origin.get.list().toList.map(nameToFile)
/** Gets the value of the <code>destination</code> attribute in a
@@ -348,7 +347,7 @@ class Scaladoc extends MatchingTask {
* @return The destination as a file.
*/
private def getDestination: File =
- if (destination.isEmpty) error("Member 'destination' is empty.")
+ if (destination.isEmpty) buildError("Member 'destination' is empty.")
else existing(getProject().resolveFile(destination.get.toString))
/** Gets the value of the <code>sourcepath</code> attribute in a
@@ -357,7 +356,7 @@ class Scaladoc extends MatchingTask {
* @return The source path as a list of files.
*/
private def getSourcepath: List[File] =
- if (sourcepath.isEmpty) error("Member 'sourcepath' is empty.")
+ if (sourcepath.isEmpty) buildError("Member 'sourcepath' is empty.")
else sourcepath.get.list().toList.map(nameToFile)
/** Gets the value of the <code>bootclasspath</code> attribute in a
@@ -366,7 +365,7 @@ class Scaladoc extends MatchingTask {
* @return The boot class path as a list of files.
*/
private def getBootclasspath: List[File] =
- if (bootclasspath.isEmpty) error("Member 'bootclasspath' is empty.")
+ if (bootclasspath.isEmpty) buildError("Member 'bootclasspath' is empty.")
else bootclasspath.get.list().toList.map(nameToFile)
/** Gets the value of the <code>extdirs</code> attribute in a
@@ -375,7 +374,7 @@ class Scaladoc extends MatchingTask {
* @return The extensions path as a list of files.
*/
private def getExtdirs: List[File] =
- if (extdirs.isEmpty) error("Member 'extdirs' is empty.")
+ if (extdirs.isEmpty) buildError("Member 'extdirs' is empty.")
else extdirs.get.list().toList.map(nameToFile)
/*============================================================================*\
@@ -437,15 +436,6 @@ class Scaladoc extends MatchingTask {
private def asString(file: File): String =
file.getAbsolutePath()
- /** Generates a build error. Error location will be the current task in the
- * ant file.
- *
- * @param message A message describing the error.
- * @throws BuildException A build error exception thrown in every case.
- */
- private def error(message: String): Nothing =
- throw new BuildException(message, getLocation())
-
/*============================================================================*\
** The big execute method **
\*============================================================================*/
@@ -453,10 +443,10 @@ class Scaladoc extends MatchingTask {
/** Initializes settings and source files */
protected def initialize: Pair[Settings, List[File]] = {
// Tests if all mandatory attributes are set and valid.
- if (origin.isEmpty) error("Attribute 'srcdir' is not set.")
- if (getOrigin.isEmpty) error("Attribute 'srcdir' is not set.")
+ if (origin.isEmpty) buildError("Attribute 'srcdir' is not set.")
+ if (getOrigin.isEmpty) buildError("Attribute 'srcdir' is not set.")
if (!destination.isEmpty && !destination.get.isDirectory())
- error("Attribute 'destdir' does not refer to an existing directory.")
+ buildError("Attribute 'destdir' does not refer to an existing directory.")
if (destination.isEmpty) destination = Some(getOrigin.head)
val mapper = new GlobPatternMapper()
@@ -501,7 +491,7 @@ class Scaladoc extends MatchingTask {
// Builds-up the compilation settings for Scalac with the existing Ant
// parameters.
- val docSettings = new Settings(error)
+ val docSettings = new Settings(buildError)
docSettings.outdir.value = asString(destination.get)
if (!classpath.isEmpty)
docSettings.classpath.value = asString(getClasspath)
@@ -532,7 +522,7 @@ class Scaladoc extends MatchingTask {
val docProcessor = new scala.tools.nsc.doc.DocFactory(reporter, docSettings)
docProcessor.document(sourceFiles.map (_.toString))
if (reporter.ERROR.count > 0)
- error(
+ buildError(
"Document failed with " +
reporter.ERROR.count + " error" +
(if (reporter.ERROR.count > 1) "s" else "") +
@@ -547,11 +537,11 @@ class Scaladoc extends MatchingTask {
} catch {
case exception: Throwable if exception.getMessage ne null =>
exception.printStackTrace()
- error("Document failed because of an internal documenter error (" +
+ buildError("Document failed because of an internal documenter error (" +
exception.getMessage + "); see the error output for details.")
case exception =>
exception.printStackTrace()
- error("Document failed because of an internal documenter error " +
+ buildError("Document failed because of an internal documenter error " +
"(no error message provided); see the error output for details.")
}
}
diff --git a/src/compiler/scala/tools/ant/sabbus/Break.scala b/src/compiler/scala/tools/ant/sabbus/Break.scala
index 95bc5cc14e..5d1f82e77a 100644
--- a/src/compiler/scala/tools/ant/sabbus/Break.scala
+++ b/src/compiler/scala/tools/ant/sabbus/Break.scala
@@ -20,7 +20,7 @@ class Break extends Task {
private var id: Option[String] = None
override def execute {
- if (id.isEmpty) error("Attribute 'id' is not set")
+ if (id.isEmpty) system.error("Attribute 'id' is not set")
Compilers.break(id.get)
}
diff --git a/src/compiler/scala/tools/ant/sabbus/Make.scala b/src/compiler/scala/tools/ant/sabbus/Make.scala
index 9173745472..31244ea7b4 100644
--- a/src/compiler/scala/tools/ant/sabbus/Make.scala
+++ b/src/compiler/scala/tools/ant/sabbus/Make.scala
@@ -14,8 +14,8 @@ import org.apache.tools.ant.Task
class Make extends Task with TaskArgs {
override def execute {
- if (id.isEmpty) error("Mandatory attribute 'id' is not set.")
- if (compilerPath.isEmpty) error("Mandatory attribute 'compilerpath' is not set.")
+ if (id.isEmpty) system.error("Mandatory attribute 'id' is not set.")
+ if (compilerPath.isEmpty) system.error("Mandatory attribute 'compilerpath' is not set.")
val settings = new Settings
if (!destinationDir.isEmpty) settings.d = destinationDir.get
if (!compTarget.isEmpty) settings.target = compTarget.get
diff --git a/src/compiler/scala/tools/ant/sabbus/ScalacFork.scala b/src/compiler/scala/tools/ant/sabbus/ScalacFork.scala
index 689df48a88..f83f476695 100644
--- a/src/compiler/scala/tools/ant/sabbus/ScalacFork.scala
+++ b/src/compiler/scala/tools/ant/sabbus/ScalacFork.scala
@@ -13,12 +13,12 @@ package sabbus
import java.io.File
import java.io.FileWriter
import org.apache.tools.ant.Project
-import org.apache.tools.ant.taskdefs.{ MatchingTask, Java }
+import org.apache.tools.ant.taskdefs.Java
import org.apache.tools.ant.util.{ GlobPatternMapper, SourceFileScanner }
import scala.tools.nsc.io
import scala.tools.nsc.util.ScalaClassLoader
-class ScalacFork extends MatchingTask with ScalacShared with TaskArgs {
+class ScalacFork extends ScalaMatchingTask with ScalacShared with TaskArgs {
private def originOfThis: String =
ScalaClassLoader.originOfClass(classOf[ScalacFork]) map (_.toString) getOrElse "<unknown>"
@@ -62,9 +62,9 @@ class ScalacFork extends MatchingTask with ScalacShared with TaskArgs {
log("Executing ant task scalacfork, origin: %s".format(originOfThis), Project.MSG_VERBOSE)
- val compilerPath = this.compilerPath getOrElse error("Mandatory attribute 'compilerpath' is not set.")
- val sourceDir = this.sourceDir getOrElse error("Mandatory attribute 'srcdir' is not set.")
- val destinationDir = this.destinationDir getOrElse error("Mandatory attribute 'destdir' is not set.")
+ val compilerPath = this.compilerPath getOrElse system.error("Mandatory attribute 'compilerpath' is not set.")
+ val sourceDir = this.sourceDir getOrElse system.error("Mandatory attribute 'srcdir' is not set.")
+ val destinationDir = this.destinationDir getOrElse system.error("Mandatory attribute 'destdir' is not set.")
val settings = new Settings
settings.d = destinationDir
@@ -114,7 +114,7 @@ class ScalacFork extends MatchingTask with ScalacShared with TaskArgs {
val res = execWithArgFiles(java, paths)
if (failOnError && res != 0)
- error("Compilation failed because of an internal compiler error;"+
+ system.error("Compilation failed because of an internal compiler error;"+
" see the error output for details.")
}
}
diff --git a/src/compiler/scala/tools/ant/sabbus/Use.scala b/src/compiler/scala/tools/ant/sabbus/Use.scala
index a466d7b18a..703cf233e1 100644
--- a/src/compiler/scala/tools/ant/sabbus/Use.scala
+++ b/src/compiler/scala/tools/ant/sabbus/Use.scala
@@ -7,15 +7,15 @@
\* */
-package scala.tools.ant.sabbus
+package scala.tools.ant
+package sabbus
import java.io.File
-import org.apache.tools.ant.taskdefs.MatchingTask
import org.apache.tools.ant.types.{Path, Reference}
import org.apache.tools.ant.util.{GlobPatternMapper, SourceFileScanner}
-class Use extends MatchingTask {
+class Use extends ScalaMatchingTask {
def setId(input: String) {
id = Some(input)
@@ -39,8 +39,8 @@ class Use extends MatchingTask {
private var failOnError: Boolean = true
override def execute() {
- if (id.isEmpty) error("Mandatory attribute 'id' is not set.")
- if (sourceDir.isEmpty) error("Mandatory attribute 'srcdir' is not set.")
+ if (id.isEmpty) system.error("Mandatory attribute 'id' is not set.")
+ if (sourceDir.isEmpty) system.error("Mandatory attribute 'srcdir' is not set.")
val compiler = Compilers(id.get)
if (!destinationDir.isEmpty) compiler.settings.d = destinationDir.get
val mapper = new GlobPatternMapper()
@@ -58,7 +58,7 @@ class Use extends MatchingTask {
log("Compiling " + includedFiles.size + " file" + (if (includedFiles.size > 1) "s" else "") + " to " + compiler.settings.d.getAbsolutePath)
val (errors, warnings) = compiler.compile(includedFiles)
if (errors > 0)
- error("Compilation failed with " + errors + " error" + (if (errors > 1) "s" else "") + ".")
+ system.error("Compilation failed with " + errors + " error" + (if (errors > 1) "s" else "") + ".")
else if (warnings > 0)
log("Compilation succeeded with " + warnings + " warning" + (if (warnings > 1) "s" else "") + ".")
}
@@ -67,7 +67,7 @@ class Use extends MatchingTask {
ex.printStackTrace
val errorMsg =
"Compilation failed because of an internal compiler error (" + msg + "); see the error output for details."
- if (failOnError) error(errorMsg) else log(errorMsg)
+ if (failOnError) system.error(errorMsg) else log(errorMsg)
}
}
diff --git a/src/compiler/scala/tools/cmd/Demo.scala b/src/compiler/scala/tools/cmd/Demo.scala
index 22cf50bd58..c471c455ae 100644
--- a/src/compiler/scala/tools/cmd/Demo.scala
+++ b/src/compiler/scala/tools/cmd/Demo.scala
@@ -48,7 +48,7 @@ object DemoSpec extends DemoSpec with Property {
type ThisCommandLine = SpecCommandLine
def creator(args: List[String]) =
new SpecCommandLine(args) {
- override def errorFn(msg: String) = { println("Error: " + msg) ; System.exit(0) }
+ override def errorFn(msg: String) = { println("Error: " + msg) ; system.exit(0) }
}
}
diff --git a/src/compiler/scala/tools/cmd/package.scala b/src/compiler/scala/tools/cmd/package.scala
index 33d3892077..a5cd7c1bc2 100644
--- a/src/compiler/scala/tools/cmd/package.scala
+++ b/src/compiler/scala/tools/cmd/package.scala
@@ -12,8 +12,7 @@ package object cmd {
def runAndExit(body: => Unit): Nothing = {
body
- System exit 0
- error("unreachable")
+ system.exit(0)
}
def toOpt(s: String) = if (s startsWith "--") s else "--" + s
diff --git a/src/compiler/scala/tools/cmd/program/Simple.scala b/src/compiler/scala/tools/cmd/program/Simple.scala
index 641be31c9e..a38239a119 100644
--- a/src/compiler/scala/tools/cmd/program/Simple.scala
+++ b/src/compiler/scala/tools/cmd/program/Simple.scala
@@ -66,8 +66,8 @@ object Simple {
* inaccessible due to the overriding var.
*/
trait Ticket2338WontFixWorkaround {
- def enforceArity_=(x: Boolean): Unit = error("unreachable")
- def onlyKnownOptions_=(x: Boolean): Unit = error("unreachable")
+ def enforceArity_=(x: Boolean): Unit = system.error("unreachable")
+ def onlyKnownOptions_=(x: Boolean): Unit = system.error("unreachable")
}
/** Configurability simplicity achieved by turning defs into vars and letting
diff --git a/src/compiler/scala/tools/nsc/CompileClient.scala b/src/compiler/scala/tools/nsc/CompileClient.scala
index c3307cba77..db5dae0cd9 100644
--- a/src/compiler/scala/tools/nsc/CompileClient.scala
+++ b/src/compiler/scala/tools/nsc/CompileClient.scala
@@ -114,7 +114,7 @@ class StandardCompileClient {
}
def main(args: Array[String]): Unit =
- exit(try main0(args) catch { case e: Exception => 1 })
+ system.exit(try main0(args) catch { case e: Exception => 1 })
}
diff --git a/src/compiler/scala/tools/nsc/CompileServer.scala b/src/compiler/scala/tools/nsc/CompileServer.scala
index 04e9b3421e..a1198409dc 100644
--- a/src/compiler/scala/tools/nsc/CompileServer.scala
+++ b/src/compiler/scala/tools/nsc/CompileServer.scala
@@ -20,8 +20,7 @@ import scala.tools.util.SocketServer
* @author Martin Odersky
* @version 1.0
*/
-class StandardCompileServer extends SocketServer
-{
+class StandardCompileServer extends SocketServer {
def compileSocket: CompileSocket = CompileSocket // todo: make this a lazy val
val versionMsg = "Fast Scala compiler " +
@@ -37,7 +36,7 @@ class StandardCompileServer extends SocketServer
private def exit(code: Int): Nothing = {
System.err.close()
System.out.close()
- Predef.exit(code)
+ system.exit(code)
}
private val runtime = Runtime.getRuntime()
@@ -91,11 +90,11 @@ class StandardCompileServer extends SocketServer
return
}
- def error(msg: String) {
+ def fscError(msg: String) {
out.println(FakePos("fsc"), msg + "\n fsc -help gives more information")
}
- val command = newOfflineCompilerCommand(args, new Settings(error))
+ val command = newOfflineCompilerCommand(args, new Settings(fscError))
reporter = new ConsoleReporter(command.settings, in, out) {
// disable prompts, so that compile server cannot block
diff --git a/src/compiler/scala/tools/nsc/CompileSocket.scala b/src/compiler/scala/tools/nsc/CompileSocket.scala
index d57016c4e9..2faa97d667 100644
--- a/src/compiler/scala/tools/nsc/CompileSocket.scala
+++ b/src/compiler/scala/tools/nsc/CompileSocket.scala
@@ -43,10 +43,10 @@ class CompileSocket {
/** A Pattern object for checking compiler output for errors */
val errorPattern = Pattern compile errorRegex
- protected def error(msg: String) = System.err.println(msg)
+ protected def fscError(msg: String) = System.err.println(msg)
protected def fatal(msg: String) = {
- error(msg)
+ fscError(msg)
throw new Exception("fsc failure")
}
@@ -147,7 +147,7 @@ class CompileSocket {
val maxAttempts = (5 * 1000) / retryDelay
def getsock(attempts: Int): Option[Socket] = attempts match {
- case 0 => error("Unable to establish connection to compilation daemon") ; None
+ case 0 => fscError("Unable to establish connection to compilation daemon") ; None
case num =>
val port = if (create) getPort(vmArgs) else pollPort()
if (port < 0) return None
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala
index 1829c75b43..bb0e122dd6 100644
--- a/src/compiler/scala/tools/nsc/Global.scala
+++ b/src/compiler/scala/tools/nsc/Global.scala
@@ -135,10 +135,13 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable
// ------------------ Reporting -------------------------------------
- def inform(msg: String) = reporter.info(NoPosition, msg, true)
- def error(msg: String) = reporter.error(NoPosition, msg)
- def warning(msg: String) =
- if (opt.fatalWarnings) error(msg)
+ // not deprecated yet, but a method called "error" imported into
+ // nearly every trait really must go. For now using globalError.
+ def error(msg: String) = globalError(msg)
+ def globalError(msg: String) = reporter.error(NoPosition, msg)
+ def inform(msg: String) = reporter.info(NoPosition, msg, true)
+ def warning(msg: String) =
+ if (opt.fatalWarnings) globalError(msg)
else reporter.warning(NoPosition, msg)
def informProgress(msg: String) = if (opt.verbose) inform("[" + msg + "]")
@@ -148,7 +151,7 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable
def logError(msg: String, t: Throwable): Unit = ()
def log(msg: => AnyRef): Unit = if (opt.logPhase) inform("[log " + phase + "] " + msg)
- def logThrowable(t: Throwable): Unit = error(throwableAsString(t))
+ def logThrowable(t: Throwable): Unit = globalError(throwableAsString(t))
def throwableAsString(t: Throwable): String =
if (opt.richExes) Exceptional(t).force().context()
else util.stringFromWriter(t printStackTrace _)
@@ -163,10 +166,10 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable
try Some(Charset.forName(name))
catch {
case _: IllegalCharsetNameException =>
- error("illegal charset name '" + name + "'")
+ globalError("illegal charset name '" + name + "'")
None
case _: UnsupportedCharsetException =>
- error("unsupported charset '" + name + "'")
+ globalError("unsupported charset '" + name + "'")
None
}
@@ -180,7 +183,7 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable
try Some(ccon.newInstance(charset.newDecoder(), reporter).asInstanceOf[SourceReader])
catch { case x =>
- error("exception while trying to instantiate source reader '" + name + "'")
+ globalError("exception while trying to instantiate source reader '" + name + "'")
None
}
}
@@ -920,19 +923,19 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable
/** Compile list of abstract files */
def compileFiles(files: List[AbstractFile]) {
try compileSources(files map getSourceFile)
- catch { case ex: IOException => error(ex.getMessage()) }
+ catch { case ex: IOException => globalError(ex.getMessage()) }
}
/** Compile list of files given by their names */
def compile(filenames: List[String]) {
try {
val sources: List[SourceFile] =
- if (isScriptRun && filenames.size > 1) returning(Nil)(_ => error("can only compile one script at a time"))
+ if (isScriptRun && filenames.size > 1) returning(Nil)(_ => globalError("can only compile one script at a time"))
else filenames map getSourceFile
compileSources(sources)
}
- catch { case ex: IOException => error(ex.getMessage()) }
+ catch { case ex: IOException => globalError(ex.getMessage()) }
}
/** Compile abstract file until `globalPhase`, but at least
@@ -1107,7 +1110,7 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable
} catch {
case ex: IOException =>
if (opt.debug) ex.printStackTrace()
- error("could not write file " + file)
+ globalError("could not write file " + file)
}
})
}
diff --git a/src/compiler/scala/tools/nsc/Interpreter.scala b/src/compiler/scala/tools/nsc/Interpreter.scala
index aeab9f75d7..57e3f904be 100644
--- a/src/compiler/scala/tools/nsc/Interpreter.scala
+++ b/src/compiler/scala/tools/nsc/Interpreter.scala
@@ -1340,7 +1340,7 @@ object Interpreter {
intLoop.createInterpreter
intLoop.in = InteractiveReader.createDefault(intLoop.interpreter)
- // rebind exit so people don't accidentally call System.exit by way of predef
+ // rebind exit so people don't accidentally call system.exit by way of predef
intLoop.interpreter.beQuietDuring {
intLoop.interpreter.interpret("""def exit = println("Type :quit to resume program execution.")""")
for (p <- args) {
diff --git a/src/compiler/scala/tools/nsc/InterpreterLoop.scala b/src/compiler/scala/tools/nsc/InterpreterLoop.scala
index a7f70b12b0..27e1be208d 100644
--- a/src/compiler/scala/tools/nsc/InterpreterLoop.scala
+++ b/src/compiler/scala/tools/nsc/InterpreterLoop.scala
@@ -32,7 +32,7 @@ trait InterpreterControl {
sealed abstract class Command extends Function1[List[String], Result] {
def name: String
def help: String
- def error(msg: String) = {
+ def commandError(msg: String) = {
out.println(":" + name + " " + msg + ".")
Result(true, None)
}
@@ -41,7 +41,7 @@ trait InterpreterControl {
case class NoArgs(name: String, help: String, f: () => Result) extends Command {
def usage(): String = ":" + name
- def apply(args: List[String]) = if (args.isEmpty) f() else error("accepts no arguments")
+ def apply(args: List[String]) = if (args.isEmpty) f() else commandError("accepts no arguments")
}
case class LineArg(name: String, help: String, f: (String) => Result) extends Command {
@@ -53,7 +53,7 @@ trait InterpreterControl {
def usage(): String = ":" + name + " <arg>"
def apply(args: List[String]) =
if (args.size == 1) f(args.head)
- else error("requires exactly one argument")
+ else commandError("requires exactly one argument")
}
case class VarArgs(name: String, help: String, f: (List[String]) => Result) extends Command {
@@ -114,7 +114,7 @@ class InterpreterLoop(in0: Option[BufferedReader], protected val out: PrintWrite
private def installSigIntHandler() {
def onExit() {
Console.println("") // avoiding "shell prompt in middle of line" syndrome
- System.exit(1)
+ system.exit(1)
}
ignoring(classOf[Exception]) {
SignalManager("INT") = {
diff --git a/src/compiler/scala/tools/nsc/Main.scala b/src/compiler/scala/tools/nsc/Main.scala
index 37fb5952e3..7f79c69f52 100644
--- a/src/compiler/scala/tools/nsc/Main.scala
+++ b/src/compiler/scala/tools/nsc/Main.scala
@@ -26,21 +26,21 @@ object Main extends AnyRef with EvalLoop {
var reporter: ConsoleReporter = _
- def error(msg: String) {
+ private def scalacError(msg: String) {
reporter.error(FakePos("scalac"), msg + "\n scalac -help gives more information")
}
def resident(compiler: Global) {
loop { line =>
val args = line.split(' ').toList
- val command = new CompilerCommand(args, new Settings(error))
+ val command = new CompilerCommand(args, new Settings(scalacError))
compiler.reporter.reset
new compiler.Run() compile command.files
}
}
def process(args: Array[String]) {
- val ss = new Settings(error)
+ val ss = new Settings(scalacError)
reporter = new ConsoleReporter(ss)
val command = new CompilerCommand(args.toList, ss)
val settings = command.settings
@@ -120,7 +120,7 @@ object Main extends AnyRef with EvalLoop {
def main(args: Array[String]) {
process(args)
- exit(if (reporter.hasErrors) 1 else 0)
+ system exit (if (reporter.hasErrors) 1 else 0)
}
}
diff --git a/src/compiler/scala/tools/nsc/MainGenericRunner.scala b/src/compiler/scala/tools/nsc/MainGenericRunner.scala
index a2d2b5b7c4..116c06179a 100644
--- a/src/compiler/scala/tools/nsc/MainGenericRunner.scala
+++ b/src/compiler/scala/tools/nsc/MainGenericRunner.scala
@@ -31,7 +31,7 @@ object MainGenericRunner {
def main(args: Array[String]) {
if (!process(args))
- System.exit(1)
+ system.exit(1)
}
def process(args: Array[String]): Boolean = {
diff --git a/src/compiler/scala/tools/nsc/MainTokenMetric.scala b/src/compiler/scala/tools/nsc/MainTokenMetric.scala
index fc0ea67051..33e91759f8 100644
--- a/src/compiler/scala/tools/nsc/MainTokenMetric.scala
+++ b/src/compiler/scala/tools/nsc/MainTokenMetric.scala
@@ -34,7 +34,7 @@ object MainTokenMetric {
}
def process(args: Array[String]) {
- val settings = new Settings(error)
+ val settings = new Settings(system.error)
reporter = new ConsoleReporter(settings)
val command = new CompilerCommand(args.toList, settings)
try {
@@ -50,7 +50,7 @@ object MainTokenMetric {
def main(args: Array[String]) {
process(args)
- exit(if (reporter.hasErrors) 1 else 0)
+ system.exit(if (reporter.hasErrors) 1 else 0)
}
}
diff --git a/src/compiler/scala/tools/nsc/PhaseAssembly.scala b/src/compiler/scala/tools/nsc/PhaseAssembly.scala
index e0cc91cb80..c121098d56 100644
--- a/src/compiler/scala/tools/nsc/PhaseAssembly.scala
+++ b/src/compiler/scala/tools/nsc/PhaseAssembly.scala
@@ -255,7 +255,7 @@ trait PhaseAssembly { self: Global =>
val tonode = graph.getNodeByPhase(phsname)
graph.softConnectNodes(fromnode, tonode)
} else {
- error("[phase assembly, after dependency on terminal phase not allowed: " + fromnode.phasename + " => "+ phsname + "]")
+ globalError("[phase assembly, after dependency on terminal phase not allowed: " + fromnode.phasename + " => "+ phsname + "]")
}
}
for (phsname <- phs.runsBefore) {
@@ -263,7 +263,7 @@ trait PhaseAssembly { self: Global =>
val tonode = graph.getNodeByPhase(phsname)
graph.softConnectNodes(tonode, fromnode)
} else {
- error("[phase assembly, before dependency on parser phase not allowed: " + phsname + " => "+ fromnode.phasename + "]")
+ globalError("[phase assembly, before dependency on parser phase not allowed: " + phsname + " => "+ fromnode.phasename + "]")
}
}
case Some(phsname) =>
@@ -271,7 +271,7 @@ trait PhaseAssembly { self: Global =>
val tonode = graph.getNodeByPhase(phsname)
graph.hardConnectNodes(fromnode, tonode)
} else {
- error("[phase assembly, right after dependency on terminal phase not allowed: " + fromnode.phasename + " => "+ phsname + "]")
+ globalError("[phase assembly, right after dependency on terminal phase not allowed: " + fromnode.phasename + " => "+ phsname + "]")
}
}
}
diff --git a/src/compiler/scala/tools/nsc/ScalaDoc.scala b/src/compiler/scala/tools/nsc/ScalaDoc.scala
index 4354608e10..0549e2c758 100644
--- a/src/compiler/scala/tools/nsc/ScalaDoc.scala
+++ b/src/compiler/scala/tools/nsc/ScalaDoc.scala
@@ -25,14 +25,14 @@ object ScalaDoc {
var reporter: ConsoleReporter = _
- def error(msg: String): Unit = {
+ private def scalacError(msg: String): Unit = {
reporter.error(FakePos("scalac"), msg + "\n scalac -help gives more information")
}
def process(args: Array[String]): Unit = {
val docSettings: doc.Settings =
- new doc.Settings(error)
+ new doc.Settings(scalacError)
reporter = new ConsoleReporter(docSettings) {
override def hasErrors = false // need to do this so that the Global instance doesn't trash all the symbols just because there was an error
@@ -79,7 +79,6 @@ object ScalaDoc {
def main(args: Array[String]): Unit = {
process(args)
- exit(if (reporter.hasErrors) 1 else 0)
+ system.exit(if (reporter.hasErrors) 1 else 0)
}
-
}
diff --git a/src/compiler/scala/tools/nsc/ScriptRunner.scala b/src/compiler/scala/tools/nsc/ScriptRunner.scala
index cae2219adf..c8085e58a1 100644
--- a/src/compiler/scala/tools/nsc/ScriptRunner.scala
+++ b/src/compiler/scala/tools/nsc/ScriptRunner.scala
@@ -134,7 +134,7 @@ object ScriptRunner {
scriptFileIn: String): Boolean =
{
val scriptFile = Path(scriptFileIn).toAbsolute.path
- val compSettingNames = new Settings(error).visibleSettings.toList map (_.name)
+ val compSettingNames = new Settings(system.error).visibleSettings.toList map (_.name)
val compSettings = settings.visibleSettings.toList filter (compSettingNames contains _.name)
val coreCompArgs = compSettings flatMap (_.unparse)
val compArgs = coreCompArgs ::: List("-Xscript", scriptMain(settings), scriptFile)
@@ -198,7 +198,7 @@ object ScriptRunner {
else None
}
- /** The script runner calls System.exit to communicate a return value, but this must
+ /** The script runner calls system.exit to communicate a return value, but this must
* not take place until there are no non-daemon threads running. Tickets #1955, #2006.
*/
waitingForThreads {
diff --git a/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala b/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala
index a5bf1dfd0c..82c09b6501 100644
--- a/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala
@@ -684,7 +684,7 @@ abstract class TreeBrowsers {
toDocument(thistpe) :/: ", " :/:
toDocument(supertpe) ::")"))
case _ =>
- Predef.error("Unknown case: " + t.toString() +", "+ t.getClass)
+ system.error("Unknown case: " + t.toString() +", "+ t.getClass)
}
}
diff --git a/src/compiler/scala/tools/nsc/backend/icode/ExceptionHandlers.scala b/src/compiler/scala/tools/nsc/backend/icode/ExceptionHandlers.scala
index 89c5ca18a9..e38d14c10b 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/ExceptionHandlers.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/ExceptionHandlers.scala
@@ -75,8 +75,8 @@ trait ExceptionHandlers {
}
object NoFinalizer extends Finalizer(null, "<no finalizer>", NoPosition) {
- override def startBlock: BasicBlock = error("NoFinalizer cannot have a start block.");
- override def setStartBlock(b: BasicBlock): Unit = error("NoFinalizer cannot have a start block.");
+ override def startBlock: BasicBlock = system.error("NoFinalizer cannot have a start block.");
+ override def setStartBlock(b: BasicBlock): Unit = system.error("NoFinalizer cannot have a start block.");
override def dup = this
}
}
diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
index 7744a57547..0e2c39aeee 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
@@ -122,7 +122,7 @@ abstract class GenICode extends SubComponent {
case Block(_, Return(_)) => ()
case Return(_) => ()
case EmptyTree =>
- error("Concrete method has no definition: " + tree)
+ globalError("Concrete method has no definition: " + tree)
case _ => if (ctx1.bb.isEmpty)
ctx1.bb.closeWith(RETURN(m.returnType), rhs.pos)
else
diff --git a/src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala b/src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala
index 8e92beebc3..3beab98237 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/ICodeCheckers.scala
@@ -7,7 +7,8 @@ package scala.tools.nsc
package backend
package icode
-import scala.collection.mutable.{Buffer, ListBuffer, Map, HashMap}
+import scala.collection.mutable
+import scala.collection.mutable.ListBuffer
import scala.tools.nsc.symtab._
abstract class ICodeCheckers {
@@ -59,8 +60,8 @@ abstract class ICodeCheckers {
var method: IMethod = _
var code: Code = _
- val in: Map[BasicBlock, TypeStack] = new HashMap()
- val out: Map[BasicBlock, TypeStack] = new HashMap()
+ val in: mutable.Map[BasicBlock, TypeStack] = new mutable.HashMap()
+ val out: mutable.Map[BasicBlock, TypeStack] = new mutable.HashMap()
val emptyStack = new TypeStack() {
override def toString = "<empty>"
}
@@ -113,11 +114,11 @@ abstract class ICodeCheckers {
for (f1 <- cls.fields ; f2 <- cls.fields ; if f1 < f2)
if (isConfict(f1, f2, false))
- ICodeCheckers.this.global.error("Repetitive field name: " + f1.symbol.fullName)
+ icodeError("Repetitive field name: " + f1.symbol.fullName)
for (m1 <- cls.methods ; m2 <- cls.methods ; if m1 < m2)
if (isConfict(m1, m2, true))
- ICodeCheckers.this.global.error("Repetitive method: " + m1.symbol.fullName)
+ icodeError("Repetitive method: " + m1.symbol.fullName)
clasz.methods foreach check
}
@@ -130,7 +131,7 @@ abstract class ICodeCheckers {
}
def check(c: Code) {
- val worklist: Buffer[BasicBlock] = new ListBuffer()
+ val worklist = new ListBuffer[BasicBlock]
def append(elems: List[BasicBlock]) =
worklist ++= (elems filterNot (worklist contains _))
@@ -284,7 +285,7 @@ abstract class ICodeCheckers {
var stack = new TypeStack(initial)
def checkStack(len: Int) {
if (stack.length < len)
- ICodeChecker.this.error("Expected at least " + len + " elements on the stack", stack)
+ ICodeChecker.this.icodeError("Expected at least " + len + " elements on the stack", stack)
}
def sizeString(push: Boolean) = {
@@ -301,7 +302,7 @@ abstract class ICodeCheckers {
}
def _popStack: TypeKind = {
if (stack.isEmpty) {
- error("Popped empty stack in " + b.fullString + ", throwing a Unit")
+ icodeError("Popped empty stack in " + b.fullString + ", throwing a Unit")
return UNIT
}
stack.pop
@@ -337,7 +338,7 @@ abstract class ICodeCheckers {
}
def typeError(k1: TypeKind, k2: TypeKind) {
- error("\n expected: " + k1 + "\n found: " + k2)
+ icodeError("\n expected: " + k1 + "\n found: " + k2)
}
def isSubtype(k1: TypeKind, k2: TypeKind) = (k1 <:< k2) || {
import platform.isMaybeBoxed
@@ -368,21 +369,21 @@ abstract class ICodeCheckers {
def checkLocal(local: Local): Unit = {
method lookupLocal local.sym.name getOrElse {
- error(" " + local + " is not defined in method " + method)
+ icodeError(" " + local + " is not defined in method " + method)
}
}
def checkField(obj: TypeKind, field: Symbol): Unit = obj match {
case REFERENCE(sym) =>
if (sym.info.member(field.name) == NoSymbol)
- error(" " + field + " is not defined in class " + clasz);
+ icodeError(" " + field + " is not defined in class " + clasz);
case _ =>
- error(" expected reference type, but " + obj + " found");
+ icodeError(" expected reference type, but " + obj + " found");
}
/** Checks that tpe is a subtype of one of the allowed types */
def checkType(tpe: TypeKind, allowed: TypeKind*) = (
if (allowed exists (k => isSubtype(tpe, k))) ()
- else error(tpe + " is not one of: " + allowed.mkString("{ ", ", ", " }"))
+ else icodeError(tpe + " is not one of: " + allowed.mkString("{ ", ", ", " }"))
)
def checkNumeric(tpe: TypeKind) =
checkType(tpe, BYTE, CHAR, SHORT, INT, LONG, FLOAT, DOUBLE)
@@ -437,11 +438,11 @@ abstract class ICodeCheckers {
"Method " + method + " does not exist in " + receiver)
case t =>
- error("Not a reference type: " + t)
+ icodeError("Not a reference type: " + t)
}
def checkBool(cond: Boolean, msg: String) =
- if (!cond) error(msg)
+ if (!cond) icodeError(msg)
if (settings.debug.value) {
log("PC: " + instr)
@@ -461,7 +462,7 @@ abstract class ICodeCheckers {
subtypeTest(elem, kind)
pushStack(elem)
case (a, b) =>
- error(" expected and INT and a array reference, but " +
+ icodeError(" expected and INT and a array reference, but " +
a + ", " + b + " found");
}
@@ -486,7 +487,7 @@ abstract class ICodeCheckers {
case STORE_THIS(kind) =>
val actualType = popStack
if (actualType.isReferenceType) subtypeTest(actualType, kind)
- else error("Expected this reference but found: " + actualType)
+ else icodeError("Expected this reference but found: " + actualType)
case STORE_ARRAY_ITEM(kind) =>
popStack3 match {
@@ -494,7 +495,7 @@ abstract class ICodeCheckers {
subtypeTest(k, kind)
subtypeTest(k, elem)
case (a, b, c) =>
- error(" expected and array reference, and int and " + kind +
+ icodeError(" expected and array reference, and int and " + kind +
" but " + a + ", " + b + ", " + c + " found");
}
@@ -564,7 +565,7 @@ abstract class ICodeCheckers {
case ArrayLength(kind) =>
popStack match {
case ARRAY(elem) => checkType(elem, kind)
- case arr => error(" array reference expected, but " + arr + " found")
+ case arr => icodeError(" array reference expected, but " + arr + " found")
}
pushStack(INT)
@@ -695,16 +696,16 @@ abstract class ICodeCheckers {
//////////////// Error reporting /////////////////////////
- def error(msg: String) {
- ICodeCheckers.this.global.error(
+ def icodeError(msg: String) {
+ ICodeCheckers.this.global.globalError(
"!! ICode checker fatality in " + method +
"\n at: " + basicBlock.fullString +
"\n error message: " + msg
)
}
- def error(msg: String, stack: TypeStack) {
- error(msg + "\n type stack: " + stack)
+ def icodeError(msg: String, stack: TypeStack) {
+ icodeError(msg + "\n type stack: " + stack)
}
}
}
diff --git a/src/compiler/scala/tools/nsc/backend/icode/Linearizers.scala b/src/compiler/scala/tools/nsc/backend/icode/Linearizers.scala
index 9bb704f8b7..05259772f4 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/Linearizers.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/Linearizers.scala
@@ -196,7 +196,7 @@ trait Linearizers { self: ICodes =>
m.code.blocks.toList;
def linearizeAt(m: IMethod, start: BasicBlock): List[BasicBlock] = {
- error("not implemented")
+ system.error("not implemented")
}
}
@@ -335,7 +335,7 @@ trait Linearizers { self: ICodes =>
}
def linearizeAt(m: IMethod, start: BasicBlock): List[BasicBlock] = {
- error("not implemented")
+ system.error("not implemented")
}
}
}
diff --git a/src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala b/src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala
index 5ee4245e35..6da0279ffe 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/Opcodes.scala
@@ -578,7 +578,7 @@ trait Opcodes { self: ICodes =>
* then pushes one exception instance.
*/
case class LOAD_EXCEPTION(clasz: Symbol) extends Instruction {
- override def consumed = error("LOAD_EXCEPTION does clean the whole stack, no idea how many things it consumes!")
+ override def consumed = system.error("LOAD_EXCEPTION does clean the whole stack, no idea how many things it consumes!")
override def produced = 1
override def producedTypes = REFERENCE(clasz) :: Nil
}
diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala
index 5ac44380f2..3d7219923d 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala
@@ -301,7 +301,7 @@ abstract class CopyPropagation {
out.bindings += (LocalVar(local) -> v)
}
case Nil =>
- Predef.error("Incorrect icode in " + method + ". Expecting something on the stack.")
+ system.error("Incorrect icode in " + method + ". Expecting something on the stack.")
}
out.stack = out.stack drop 1;
diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/DataFlowAnalysis.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/DataFlowAnalysis.scala
index 98d9081624..be50640d9c 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/analysis/DataFlowAnalysis.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/DataFlowAnalysis.scala
@@ -83,7 +83,7 @@ trait DataFlowAnalysis[L <: SemiLattice] {
Console.println("in: " + in.mkString("", "\n", ""))
Console.println("out: " + out.mkString("", "\n", ""))
e.printStackTrace
- Predef.error("Could not find element " + e.getMessage)
+ system.error("Could not find element " + e.getMessage)
}
/** ...
diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala
index ec36e50205..03bb2bae3f 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/TypeFlowAnalysis.scala
@@ -46,7 +46,7 @@ abstract class TypeFlowAnalysis {
def lub2(exceptional: Boolean)(s1: TypeStack, s2: TypeStack) = {
if (s1 eq bottom) s2
else if (s2 eq bottom) s1
- else if ((s1 eq exceptionHandlerStack) || (s2 eq exceptionHandlerStack)) Predef.error("merging with exhan stack")
+ else if ((s1 eq exceptionHandlerStack) || (s2 eq exceptionHandlerStack)) system.error("merging with exhan stack")
else {
// if (s1.length != s2.length)
// throw new CheckerException("Incompatible stacks: " + s1 + " and " + s2);
diff --git a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala
index 4005b4e5c9..9b7bb3444a 100644
--- a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala
+++ b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala
@@ -300,7 +300,7 @@ abstract class Inliners extends SubComponent {
def isMonadic = isMonadicMethod(sym)
def handlers = m.exh
- def blocks = if (m.code eq null) Predef.error("blocks = null + " + m) else m.code.blocks
+ def blocks = if (m.code eq null) system.error("blocks = null + " + m) else m.code.blocks
def locals = m.locals
def length = blocks.length
def openBlocks = blocks filterNot (_.closed)
diff --git a/src/compiler/scala/tools/nsc/interactive/BuildManager.scala b/src/compiler/scala/tools/nsc/interactive/BuildManager.scala
index 302bba0e07..2827d97ae2 100644
--- a/src/compiler/scala/tools/nsc/interactive/BuildManager.scala
+++ b/src/compiler/scala/tools/nsc/interactive/BuildManager.scala
@@ -51,7 +51,7 @@ object BuildManagerTest extends EvalLoop {
def prompt = "builder > "
- def error(msg: String) {
+ private def buildError(msg: String) {
println(msg + "\n scalac -help gives more information")
}
@@ -67,7 +67,7 @@ object BuildManagerTest extends EvalLoop {
Set.empty ++ result._1
}
- val settings = new Settings(error)
+ val settings = new Settings(buildError)
settings.Ybuildmanagerdebug.value = true
val command = new CompilerCommand(args.toList, settings)
// settings.make.value = "off"
diff --git a/src/compiler/scala/tools/nsc/interactive/REPL.scala b/src/compiler/scala/tools/nsc/interactive/REPL.scala
index 775b979851..4225460d1c 100644
--- a/src/compiler/scala/tools/nsc/interactive/REPL.scala
+++ b/src/compiler/scala/tools/nsc/interactive/REPL.scala
@@ -20,13 +20,13 @@ object REPL {
var reporter: ConsoleReporter = _
- def error(msg: String) {
+ private def replError(msg: String) {
reporter.error(/*new Position */FakePos("scalac"),
msg + "\n scalac -help gives more information")
}
def process(args: Array[String]) {
- val settings = new Settings(error)
+ val settings = new Settings(replError)
reporter = new ConsoleReporter(settings)
val command = new CompilerCommand(args.toList, settings)
if (command.settings.version.value)
@@ -56,7 +56,7 @@ object REPL {
def main(args: Array[String]) {
process(args)
- exit(if (reporter.hasErrors) 1 else 0)
+ system.exit(if (reporter.hasErrors) 1 else 0)
}
def loop(action: (String) => Unit) {
@@ -109,7 +109,7 @@ object REPL {
case List("complete", file, off1) =>
doComplete(makePos(file, off1, off1))
case List("quit") =>
- System.exit(1)
+ system.exit(1)
case _ =>
println("unrecongized command")
}
diff --git a/src/compiler/scala/tools/nsc/interactive/RangePositions.scala b/src/compiler/scala/tools/nsc/interactive/RangePositions.scala
index cf66c80b02..1853abebe8 100644
--- a/src/compiler/scala/tools/nsc/interactive/RangePositions.scala
+++ b/src/compiler/scala/tools/nsc/interactive/RangePositions.scala
@@ -190,7 +190,7 @@ self: scala.tools.nsc.Global =>
inform("")
}
- def error(msg: String)(body : => Unit) {
+ def positionError(msg: String)(body : => Unit) {
inform("======= Bad positions: "+msg)
inform("")
body
@@ -205,15 +205,15 @@ self: scala.tools.nsc.Global =>
def validate(tree: Tree, encltree: Tree): Unit = {
if (!tree.isEmpty) {
if (!tree.pos.isDefined)
- error("Unpositioned tree ["+tree.id+"]") { reportTree("Unpositioned", tree) }
+ positionError("Unpositioned tree ["+tree.id+"]") { reportTree("Unpositioned", tree) }
if (tree.pos.isRange) {
if (!encltree.pos.isRange)
- error("Synthetic tree ["+encltree.id+"] contains nonsynthetic tree ["+tree.id+"]") {
+ positionError("Synthetic tree ["+encltree.id+"] contains nonsynthetic tree ["+tree.id+"]") {
reportTree("Enclosing", encltree)
reportTree("Enclosed", tree)
}
if (!(encltree.pos includes tree.pos))
- error("Enclosing tree ["+encltree.id+"] does not include tree ["+tree.id+"]") {
+ positionError("Enclosing tree ["+encltree.id+"] does not include tree ["+tree.id+"]") {
reportTree("Enclosing", encltree)
reportTree("Enclosed", tree)
}
@@ -221,7 +221,7 @@ self: scala.tools.nsc.Global =>
findOverlapping(tree.children flatMap solidDescendants) match {
case List() => ;
case xs => {
- error("Overlapping trees "+xs.map { case (x, y) => (x.id, y.id) }.mkString("", ", ", "")) {
+ positionError("Overlapping trees "+xs.map { case (x, y) => (x.id, y.id) }.mkString("", ", ", "")) {
reportTree("Ancestor", tree)
for((x, y) <- xs) {
reportTree("First overlapping", x)
diff --git a/src/compiler/scala/tools/nsc/interactive/tests/Tester.scala b/src/compiler/scala/tools/nsc/interactive/tests/Tester.scala
index 57c38b209d..6e380027b6 100644
--- a/src/compiler/scala/tools/nsc/interactive/tests/Tester.scala
+++ b/src/compiler/scala/tools/nsc/interactive/tests/Tester.scala
@@ -199,6 +199,6 @@ object Tester {
println("filenames = "+filenames)
val files = filenames.toArray map (str => new BatchSourceFile(AbstractFile.getFile(str)): SourceFile)
new Tester(args(0).toInt, files, settings).run()
- System.exit(0)
+ system.exit(0)
}
}
diff --git a/src/compiler/scala/tools/nsc/interpreter/InteractiveReader.scala b/src/compiler/scala/tools/nsc/interpreter/InteractiveReader.scala
index 840e457dd4..014fd62a0c 100644
--- a/src/compiler/scala/tools/nsc/interpreter/InteractiveReader.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/InteractiveReader.scala
@@ -21,7 +21,7 @@ trait InteractiveReader {
def readLine(prompt: String): String = {
def handler: Catcher[String] = {
- case e: ClosedByInterruptException => error("Reader closed by interrupt.")
+ case e: ClosedByInterruptException => system.error("Reader closed by interrupt.")
// Terminal has to be re-initialized after SIGSTP or up arrow etc. stop working.
case e: IOException if restartSystemCall(e) => init() ; readLine(prompt)
}
diff --git a/src/compiler/scala/tools/nsc/interpreter/ReflectionCompletion.scala b/src/compiler/scala/tools/nsc/interpreter/ReflectionCompletion.scala
index fd090db89e..70f1ffa5a7 100644
--- a/src/compiler/scala/tools/nsc/interpreter/ReflectionCompletion.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/ReflectionCompletion.scala
@@ -21,12 +21,12 @@ trait ReflectionCompletion extends CompletionAware {
def reflectName(m: AccessibleObject) = m match {
case x: reflect.Method => x.getName
case x: reflect.Field => x.getName
- case x => error(x.toString)
+ case x => system.error(x.toString)
}
def isPublic(m: AccessibleObject) = m match {
case x: reflect.Method => Modifier isPublic x.getModifiers
case x: reflect.Field => Modifier isPublic x.getModifiers
- case x => error(x.toString)
+ case x => system.error(x.toString)
}
lazy val (staticMethods, instanceMethods) = clazz.getMethods.toList partition (x => isStatic(x.getModifiers))
diff --git a/src/compiler/scala/tools/nsc/io/VirtualDirectory.scala b/src/compiler/scala/tools/nsc/io/VirtualDirectory.scala
index b4b1eca439..eac7530aa3 100644
--- a/src/compiler/scala/tools/nsc/io/VirtualDirectory.scala
+++ b/src/compiler/scala/tools/nsc/io/VirtualDirectory.scala
@@ -27,8 +27,8 @@ extends AbstractFile {
var lastModified: Long = System.currentTimeMillis
override def file = null
- override def input = error("directories cannot be read")
- override def output = error("directories cannot be written")
+ override def input = system.error("directories cannot be read")
+ override def output = system.error("directories cannot be written")
/** Does this abstract file denote an existing file? */
def create { unsupported }
diff --git a/src/compiler/scala/tools/nsc/plugins/Plugins.scala b/src/compiler/scala/tools/nsc/plugins/Plugins.scala
index 5823a09995..c798fa89e1 100644
--- a/src/compiler/scala/tools/nsc/plugins/Plugins.scala
+++ b/src/compiler/scala/tools/nsc/plugins/Plugins.scala
@@ -75,7 +75,7 @@ trait Plugins
/** Verify requirements are present. */
for (req <- settings.require.value ; if !(plugs exists (_.name == req)))
- error("Missing required plugin: " + req)
+ globalError("Missing required plugin: " + req)
/** Process plugin options. */
def namec(plug: Plugin) = plug.name + ":"
@@ -86,12 +86,12 @@ trait Plugins
for (p <- plugs) {
val opts = doOpts(p)
if (!opts.isEmpty)
- p.processOptions(opts, error)
+ p.processOptions(opts, globalError)
}
/** Verify no non-existent plugin given with -P */
for (opt <- settings.pluginOptions.value ; if plugs forall (p => optList(List(opt), p).isEmpty))
- error("bad option: -P:" + opt)
+ globalError("bad option: -P:" + opt)
plugs
}
diff --git a/src/compiler/scala/tools/nsc/settings/AbsScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/AbsScalaSettings.scala
index 790f4cce00..2ef73dc9a7 100644
--- a/src/compiler/scala/tools/nsc/settings/AbsScalaSettings.scala
+++ b/src/compiler/scala/tools/nsc/settings/AbsScalaSettings.scala
@@ -34,7 +34,7 @@ trait AbsScalaSettings {
/** **/
abstract class SettingGroup(val prefix: String) extends AbsSetting {
def name = prefix
- def helpDescription: String = error("todo")
+ def helpDescription: String = system.error("todo")
def unparse: List[String] = List(name)
}
}
diff --git a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala
index d168c259e9..77428f127d 100644
--- a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala
+++ b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala
@@ -66,7 +66,7 @@ abstract class SymbolLoaders {
ok = false
if (settings.debug.value) ex.printStackTrace()
val msg = ex.getMessage()
- error(
+ globalError(
if (msg eq null) "i/o error while loading " + root.name
else "error while loading " + root.name + ", " + msg);
}
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala
index 3d19ceb04f..95d278a7a5 100644
--- a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala
+++ b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala
@@ -363,12 +363,12 @@ abstract class ICodeReader extends ClassfileParser {
case JVM.pop => code.emit(DROP(INT)) // any 1-word type would do
case JVM.pop2 => code.emit(DROP(LONG)) // any 2-word type would do
case JVM.dup => code.emit(DUP(ObjectReference)) // TODO: Is the kind inside DUP ever needed?
- case JVM.dup_x1 => code.emit(DUP_X1) // Predef.error("Unsupported JVM bytecode: dup_x1")
- case JVM.dup_x2 => code.emit(DUP_X2) // Predef.error("Unsupported JVM bytecode: dup_x2")
+ case JVM.dup_x1 => code.emit(DUP_X1) // system.error("Unsupported JVM bytecode: dup_x1")
+ case JVM.dup_x2 => code.emit(DUP_X2) // system.error("Unsupported JVM bytecode: dup_x2")
case JVM.dup2 => code.emit(DUP(LONG)) // TODO: Is the kind inside DUP ever needed?
- case JVM.dup2_x1 => code.emit(DUP2_X1) // Predef.error("Unsupported JVM bytecode: dup2_x1")
- case JVM.dup2_x2 => code.emit(DUP2_X2) // Predef.error("Unsupported JVM bytecode: dup2_x2")
- case JVM.swap => Predef.error("Unsupported JVM bytecode: swap")
+ case JVM.dup2_x1 => code.emit(DUP2_X1) // system.error("Unsupported JVM bytecode: dup2_x1")
+ case JVM.dup2_x2 => code.emit(DUP2_X2) // system.error("Unsupported JVM bytecode: dup2_x2")
+ case JVM.swap => system.error("Unsupported JVM bytecode: swap")
case JVM.iadd => code.emit(CALL_PRIMITIVE(Arithmetic(ADD, INT)))
case JVM.ladd => code.emit(CALL_PRIMITIVE(Arithmetic(ADD, LONG)))
@@ -455,8 +455,8 @@ abstract class ICodeReader extends ClassfileParser {
case JVM.if_acmpne => code.emit(LCJUMP(parseJumpTarget, pc + size, NE, ObjectReference))
case JVM.goto => emit(LJUMP(parseJumpTarget))
- case JVM.jsr => Predef.error("Cannot handle jsr/ret")
- case JVM.ret => Predef.error("Cannot handle jsr/ret")
+ case JVM.jsr => system.error("Cannot handle jsr/ret")
+ case JVM.ret => system.error("Cannot handle jsr/ret")
case JVM.tableswitch =>
val padding = if ((pc + size) % 4 != 0) 4 - ((pc + size) % 4) else 0
size += padding
@@ -581,14 +581,14 @@ abstract class ICodeReader extends ClassfileParser {
case JVM.fstore => code.emit(STORE_LOCAL(code.getLocal(in.nextChar, FLOAT))); size += 2
case JVM.dstore => code.emit(STORE_LOCAL(code.getLocal(in.nextChar, DOUBLE))); size += 2
case JVM.astore => code.emit(STORE_LOCAL(code.getLocal(in.nextChar, ObjectReference))); size += 2
- case JVM.ret => Predef.error("Cannot handle jsr/ret")
+ case JVM.ret => system.error("Cannot handle jsr/ret")
case JVM.iinc =>
size += 4
val local = code.getLocal(in.nextChar, INT)
code.emit(CONSTANT(Constant(in.nextChar)))
code.emit(CALL_PRIMITIVE(Arithmetic(ADD, INT)))
code.emit(STORE_LOCAL(local))
- case _ => Predef.error("Invalid 'wide' operand")
+ case _ => system.error("Invalid 'wide' operand")
}
case JVM.multianewarray =>
@@ -601,9 +601,9 @@ abstract class ICodeReader extends ClassfileParser {
case JVM.ifnull => code.emit(LCZJUMP(parseJumpTarget, pc + size, EQ, ObjectReference))
case JVM.ifnonnull => code.emit(LCZJUMP(parseJumpTarget, pc + size, NE, ObjectReference))
case JVM.goto_w => code.emit(LJUMP(parseJumpTargetW))
- case JVM.jsr_w => Predef.error("Cannot handle jsr/ret")
+ case JVM.jsr_w => system.error("Cannot handle jsr/ret")
-// case _ => Predef.error("Unknown bytecode")
+// case _ => system.error("Unknown bytecode")
}
pc += size
}
@@ -970,12 +970,12 @@ abstract class ICodeReader extends ClassfileParser {
def checkValidIndex {
locals.get(idx - 1) match {
case Some(others) if others exists (_._2.isWideType) =>
- error("Illegal index: " + idx + " points in the middle of another local")
+ global.globalError("Illegal index: " + idx + " points in the middle of another local")
case _ => ()
}
kind match {
case LONG | DOUBLE if (locals.isDefinedAt(idx + 1)) =>
- error("Illegal index: " + idx + " overlaps " + locals(idx + 1))
+ global.globalError("Illegal index: " + idx + " overlaps " + locals(idx + 1))
case _ => ()
}
}
diff --git a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala
index ad07cd908c..8a94442d5a 100644
--- a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala
+++ b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala
@@ -450,7 +450,7 @@ abstract class ExplicitOuter extends InfoTransform
if (sym.isClassConstructor) {
rhs match {
case Literal(_) =>
- Predef.error("unexpected case") //todo: remove
+ system.error("unexpected case") //todo: remove
case _ =>
val clazz = sym.owner
val vparamss1 =
diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
index 497450c6c4..a9f6d39cc1 100644
--- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala
+++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
@@ -580,7 +580,7 @@ abstract class UnCurry extends InfoTransform with TypingTransformers with ast.Tr
val args1 = transformTrees(fn.symbol.name match {
case nme.unapply => args
case nme.unapplySeq => transformArgs(tree.pos, fn.symbol, args, analyzer.unapplyTypeListFromReturnTypeSeq(fn.tpe))
- case _ => Predef.error("internal error: UnApply node has wrong symbol")
+ case _ => system.error("internal error: UnApply node has wrong symbol")
})
treeCopy.UnApply(tree, fn1, args1)
diff --git a/src/compiler/scala/tools/nsc/util/MsilClassPath.scala b/src/compiler/scala/tools/nsc/util/MsilClassPath.scala
index 5511326a6b..019f40d72f 100644
--- a/src/compiler/scala/tools/nsc/util/MsilClassPath.scala
+++ b/src/compiler/scala/tools/nsc/util/MsilClassPath.scala
@@ -112,7 +112,7 @@ class AssemblyClassPath(types: Array[MSILType], namespace: String, val context:
else namespace drop (i + 1)
}
def asURLs = List(new java.net.URL(name))
- def asClasspathString = error("Unknown") // I don't know what if anything makes sense here?
+ def asClasspathString = system.error("Unknown") // I don't know what if anything makes sense here?
private lazy val first: Int = {
var m = 0
diff --git a/src/compiler/scala/tools/nsc/util/ShowPickled.scala b/src/compiler/scala/tools/nsc/util/ShowPickled.scala
index 58abd721c5..a11038104b 100644
--- a/src/compiler/scala/tools/nsc/util/ShowPickled.scala
+++ b/src/compiler/scala/tools/nsc/util/ShowPickled.scala
@@ -28,10 +28,10 @@ object ShowPickled extends Names {
}
def readName =
if (isName) new String(bytes, "UTF-8")
- else error("%s is no name" format tagName)
+ else system.error("%s is no name" format tagName)
def nameIndex =
if (hasName) readNat(bytes, 0)
- else error("%s has no name" format tagName)
+ else system.error("%s has no name" format tagName)
def tagName = tag2string(tag)
override def toString = "%d,%d: %s".format(num, startIndex, tagName)
diff --git a/src/compiler/scala/tools/reflect/Mock.scala b/src/compiler/scala/tools/reflect/Mock.scala
index 1c5c880113..56bef2caa4 100644
--- a/src/compiler/scala/tools/reflect/Mock.scala
+++ b/src/compiler/scala/tools/reflect/Mock.scala
@@ -53,7 +53,7 @@ object Mock {
/** Tries to implement all the class's interfaces.
*/
def fromClass(clazz: Class[_])(pf: PartialFunction[Invoked, AnyRef]): AnyRef = allInterfaces(clazz) match {
- case Nil => Predef.error(clazz + " implements no interfaces.")
+ case Nil => system.error(clazz + " implements no interfaces.")
case x :: xs => fromInterfaces(x, xs: _*)(pf)
}
}
diff --git a/src/compiler/scala/tools/util/SocketServer.scala b/src/compiler/scala/tools/util/SocketServer.scala
index 88d7013f36..f647660193 100644
--- a/src/compiler/scala/tools/util/SocketServer.scala
+++ b/src/compiler/scala/tools/util/SocketServer.scala
@@ -42,7 +42,7 @@ abstract class SocketServer
def fatal(msg: String): Nothing = {
System.err.println(msg)
- exit(1)
+ system.exit(1)
}
private def warn(msg: String) {