diff options
author | Martin Odersky <odersky@gmail.com> | 2014-09-21 14:50:01 +0200 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2014-09-24 13:15:28 +0200 |
commit | 112d08118b5f892ba98a465ef8cf8896448245f8 (patch) | |
tree | ee204d7447d765c35bedaf1b54ffbdb8e86a1c73 /src/dotty/tools/dotc | |
parent | 23064fce9629fdf001c3138fcd8c87ba4a398a37 (diff) | |
download | dotty-112d08118b5f892ba98a465ef8cf8896448245f8.tar.gz dotty-112d08118b5f892ba98a465ef8cf8896448245f8.tar.bz2 dotty-112d08118b5f892ba98a465ef8cf8896448245f8.zip |
More accurate or postcondition conchecking in TreeChecker
Previous postcondition checking did not take into account that phases are
not flat - they consist in part of macro phases that contain miniphases.
In fact the whole set up in Run is dubiuos - we should eliminate the problem at the
root, as described in the TODO in run.
Diffstat (limited to 'src/dotty/tools/dotc')
-rw-r--r-- | src/dotty/tools/dotc/Run.scala | 8 | ||||
-rw-r--r-- | src/dotty/tools/dotc/transform/TreeChecker.scala | 14 |
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) } |