Skip to content

Commit 24825d6

Browse files
committed
Make reporter ised in Compiler configurable
Not needed right now, but will be useful later.
1 parent 6beb1b4 commit 24825d6

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/dotty/tools/dotc/Compiler.scala

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import Periods._
77
import Symbols._
88
import Scopes._
99
import typer.{FrontEnd, Typer, Mode, ImportInfo, RefChecks}
10-
import reporting.{ConsoleReporter, Reporter}
10+
import reporting.{Reporter, ConsoleReporter}
1111
import Phases.Phase
1212
import dotty.tools.dotc.transform._
1313
import dotty.tools.dotc.transform.TreeTransforms.{TreeTransform, TreeTransformer}
@@ -94,7 +94,7 @@ class Compiler {
9494
* for type checking.
9595
* imports For each element of RootImports, an import context
9696
*/
97-
def rootContext(implicit ctx: Context, r: Option[Reporter] = None): Context = {
97+
def rootContext(implicit ctx: Context): Context = {
9898
ctx.definitions.init(ctx)
9999
ctx.setPhasePlan(phases)
100100
val rootScope = new MutableScope
@@ -106,20 +106,22 @@ class Compiler {
106106
.setOwner(defn.RootClass)
107107
.setTyper(new Typer)
108108
.setMode(Mode.ImplicitsEnabled)
109-
.setTyperState(new MutableTyperState(ctx.typerState, r.getOrElse(new ConsoleReporter()(ctx)), isCommittable = true))
109+
.setTyperState(new MutableTyperState(ctx.typerState, rootReporter(ctx), isCommittable = true))
110110
ctx.definitions.init(start) // set context of definitions to start
111111
def addImport(ctx: Context, symf: () => Symbol) =
112112
ctx.fresh.setImportInfo(ImportInfo.rootImport(symf)(ctx))
113113
(start.setRunInfo(new RunInfo(start)) /: defn.RootImportFns)(addImport)
114114
}
115115

116+
protected def rootReporter(implicit ctx: Context): Reporter = new ConsoleReporter()(ctx)
117+
116118
def reset()(implicit ctx: Context): Unit = {
117119
ctx.base.reset()
118120
ctx.runInfo.clear()
119121
}
120122

121-
def newRun(implicit ctx: Context, r: Option[Reporter] = None): Run = {
123+
def newRun(implicit ctx: Context): Run = {
122124
reset()
123-
new Run(this)(rootContext(ctx, r))
125+
new Run(this)(rootContext)
124126
}
125127
}

0 commit comments

Comments
 (0)