From 24825d6862a137f69cf2e6687742173b01cc79c7 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 15 Jun 2015 17:12:01 +0200 Subject: Make reporter ised in Compiler configurable Not needed right now, but will be useful later. --- src/dotty/tools/dotc/Compiler.scala | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/dotty/tools/dotc/Compiler.scala') diff --git a/src/dotty/tools/dotc/Compiler.scala b/src/dotty/tools/dotc/Compiler.scala index e9b0a9676..6e2cab40d 100644 --- a/src/dotty/tools/dotc/Compiler.scala +++ b/src/dotty/tools/dotc/Compiler.scala @@ -7,7 +7,7 @@ import Periods._ import Symbols._ import Scopes._ import typer.{FrontEnd, Typer, Mode, ImportInfo, RefChecks} -import reporting.{ConsoleReporter, Reporter} +import reporting.{Reporter, ConsoleReporter} import Phases.Phase import dotty.tools.dotc.transform._ import dotty.tools.dotc.transform.TreeTransforms.{TreeTransform, TreeTransformer} @@ -94,7 +94,7 @@ class Compiler { * for type checking. * imports For each element of RootImports, an import context */ - def rootContext(implicit ctx: Context, r: Option[Reporter] = None): Context = { + def rootContext(implicit ctx: Context): Context = { ctx.definitions.init(ctx) ctx.setPhasePlan(phases) val rootScope = new MutableScope @@ -106,20 +106,22 @@ class Compiler { .setOwner(defn.RootClass) .setTyper(new Typer) .setMode(Mode.ImplicitsEnabled) - .setTyperState(new MutableTyperState(ctx.typerState, r.getOrElse(new ConsoleReporter()(ctx)), isCommittable = true)) + .setTyperState(new MutableTyperState(ctx.typerState, rootReporter(ctx), isCommittable = true)) ctx.definitions.init(start) // set context of definitions to start def addImport(ctx: Context, symf: () => Symbol) = ctx.fresh.setImportInfo(ImportInfo.rootImport(symf)(ctx)) (start.setRunInfo(new RunInfo(start)) /: defn.RootImportFns)(addImport) } + protected def rootReporter(implicit ctx: Context): Reporter = new ConsoleReporter()(ctx) + def reset()(implicit ctx: Context): Unit = { ctx.base.reset() ctx.runInfo.clear() } - def newRun(implicit ctx: Context, r: Option[Reporter] = None): Run = { + def newRun(implicit ctx: Context): Run = { reset() - new Run(this)(rootContext(ctx, r)) + new Run(this)(rootContext) } } -- cgit v1.2.3