aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/Driver.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/dotty/tools/dotc/Driver.scala')
-rw-r--r--src/dotty/tools/dotc/Driver.scala19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/dotty/tools/dotc/Driver.scala b/src/dotty/tools/dotc/Driver.scala
index 13604d9cc..e5e031e79 100644
--- a/src/dotty/tools/dotc/Driver.scala
+++ b/src/dotty/tools/dotc/Driver.scala
@@ -3,6 +3,7 @@ package dotty.tools.dotc
import config.CompilerCommand
import core.Contexts.{Context, ContextBase}
import core.DotClass
+import reporting._
abstract class Driver extends DotClass {
@@ -10,33 +11,37 @@ abstract class Driver extends DotClass {
protected def newCompiler(): Compiler
- protected def doCompile(compiler: Compiler, fileNames: List[String])(implicit ctx: Context) =
+ protected def emptyReporter = new StoreReporter
+
+ protected def doCompile(compiler: Compiler, fileNames: List[String])(implicit ctx: Context): Reporter =
if (fileNames.nonEmpty) {
val run = compiler.newRun
run.compile(fileNames)
run.printSummary()
- }
+ } else emptyReporter
protected def initCtx = (new ContextBase).initialCtx
- def process(args: Array[String]): Boolean = {
+ def process(args: Array[String]): Reporter = {
val summary = CompilerCommand.distill(args)(initCtx)
implicit val ctx = initCtx.fresh.withSettings(summary.sstate)
val fileNames = CompilerCommand.checkUsage(summary)
try {
doCompile(newCompiler(), fileNames)
- !ctx.reporter.hasErrors
} catch {
case ex: Throwable =>
ex match {
- case ex: FatalError => ctx.error(ex.getMessage); false // signals that we should fail compilation.
- case _ => throw ex // unexpected error, tell the outside world.
+ case ex: FatalError =>
+ ctx.error(ex.getMessage) // signals that we should fail compilation.
+ ctx.typerState.reporter
+ case _ =>
+ throw ex // unexpected error, tell the outside world.
}
}
}
def main(args: Array[String]): Unit =
- sys.exit(if (process(args)) 1 else 0)
+ sys.exit(if (process(args).hasErrors) 1 else 0)
}
class FatalError(msg: String) extends Exception