aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dotty/tools/dotc/Run.scala8
-rw-r--r--src/dotty/tools/dotc/transform/TreeChecker.scala14
2 files changed, 20 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/Run.scala b/src/dotty/tools/dotc/Run.scala
index 1f79df9aa..ad0e83d59 100644
--- a/src/dotty/tools/dotc/Run.scala
+++ b/src/dotty/tools/dotc/Run.scala
@@ -28,6 +28,12 @@ class Run(comp: Compiler)(implicit ctx: Context) {
compileSources(sources)
}
+ /** TODO: There's a fundamental design problem here: We assmble phases using `squash`
+ * when we first build the compiler. But we modify them with -Yskip, -Ystop
+ * on each run. That modification needs to either trasnform the tree structure,
+ * or we need to assmeble phases on each run, and take -Yskip, -Ystop into
+ * account. I think the latter would be preferable.
+ */
def compileSources(sources: List[SourceFile]) = Stats.monitorHeartBeat {
if (sources forall (_.exists)) {
units = sources map (new CompilationUnit(_))
@@ -36,7 +42,7 @@ class Run(comp: Compiler)(implicit ctx: Context) {
ctx.settings.YstopAfter.value.containsPhase(phase.prev)
val phasesToRun = ctx.allPhases.init
.takeWhile(!stoppedBefore(_))
- .filterNot(ctx.settings.Yskip.value.containsPhase(_))
+ .filterNot(ctx.settings.Yskip.value.containsPhase(_)) // TODO: skip only subphase
for (phase <- phasesToRun)
if (!ctx.reporter.hasErrors) {
phase.runOn(units)
diff --git a/src/dotty/tools/dotc/transform/TreeChecker.scala b/src/dotty/tools/dotc/transform/TreeChecker.scala
index 6d6a88e36..cf32df61b 100644
--- a/src/dotty/tools/dotc/transform/TreeChecker.scala
+++ b/src/dotty/tools/dotc/transform/TreeChecker.scala
@@ -35,11 +35,23 @@ import java.lang.AssertionError
class TreeChecker {
import ast.tpd._
+ private def previousPhases(phases: List[Phase])(implicit ctx: Context): List[Phase] = phases match {
+ case (phase: TreeTransformer) :: phases1 =>
+ val subPhases = phase.transformations.map(_.phase)
+ val previousSubPhases = previousPhases(subPhases.toList)
+ if (previousSubPhases.length == subPhases.length) previousSubPhases ::: previousPhases(phases1)
+ else previousSubPhases
+ case phase :: phases1 if phase ne ctx.phase =>
+ phase :: previousPhases(phases1)
+ case _ =>
+ Nil
+ }
+
def check(phasesToRun: Seq[Phase], ctx: Context) = {
println(s"checking ${ctx.compilationUnit} after phase ${ctx.phase.prev}")
val checkingCtx = ctx.fresh
.setTyperState(ctx.typerState.withReporter(new ThrowingReporter(ctx.typerState.reporter)))
- val checker = new Checker(phasesToRun.takeWhile(_ ne ctx.phase))
+ val checker = new Checker(previousPhases(phasesToRun.toList)(ctx))
checker.typedExpr(ctx.compilationUnit.tpdTree)(checkingCtx)
}