File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,12 @@ class Run(comp: Compiler)(implicit ctx: Context) {
28
28
compileSources(sources)
29
29
}
30
30
31
+ /** TODO: There's a fundamental design problem here: We assmble phases using `squash`
32
+ * when we first build the compiler. But we modify them with -Yskip, -Ystop
33
+ * on each run. That modification needs to either trasnform the tree structure,
34
+ * or we need to assmeble phases on each run, and take -Yskip, -Ystop into
35
+ * account. I think the latter would be preferable.
36
+ */
31
37
def compileSources (sources : List [SourceFile ]) = Stats .monitorHeartBeat {
32
38
if (sources forall (_.exists)) {
33
39
units = sources map (new CompilationUnit (_))
@@ -36,7 +42,7 @@ class Run(comp: Compiler)(implicit ctx: Context) {
36
42
ctx.settings.YstopAfter .value.containsPhase(phase.prev)
37
43
val phasesToRun = ctx.allPhases.init
38
44
.takeWhile(! stoppedBefore(_))
39
- .filterNot(ctx.settings.Yskip .value.containsPhase(_))
45
+ .filterNot(ctx.settings.Yskip .value.containsPhase(_)) // TODO: skip only subphase
40
46
for (phase <- phasesToRun)
41
47
if (! ctx.reporter.hasErrors) {
42
48
phase.runOn(units)
Original file line number Diff line number Diff line change @@ -35,11 +35,23 @@ import java.lang.AssertionError
35
35
class TreeChecker {
36
36
import ast .tpd ._
37
37
38
+ private def previousPhases (phases : List [Phase ])(implicit ctx : Context ): List [Phase ] = phases match {
39
+ case (phase : TreeTransformer ) :: phases1 =>
40
+ val subPhases = phase.transformations.map(_.phase)
41
+ val previousSubPhases = previousPhases(subPhases.toList)
42
+ if (previousSubPhases.length == subPhases.length) previousSubPhases ::: previousPhases(phases1)
43
+ else previousSubPhases
44
+ case phase :: phases1 if phase ne ctx.phase =>
45
+ phase :: previousPhases(phases1)
46
+ case _ =>
47
+ Nil
48
+ }
49
+
38
50
def check (phasesToRun : Seq [Phase ], ctx : Context ) = {
39
51
println(s " checking ${ctx.compilationUnit} after phase ${ctx.phase.prev}" )
40
52
val checkingCtx = ctx.fresh
41
53
.setTyperState(ctx.typerState.withReporter(new ThrowingReporter (ctx.typerState.reporter)))
42
- val checker = new Checker (phasesToRun.takeWhile(_ ne ctx.phase ))
54
+ val checker = new Checker (previousPhases( phasesToRun.toList)( ctx))
43
55
checker.typedExpr(ctx.compilationUnit.tpdTree)(checkingCtx)
44
56
}
45
57
You can’t perform that action at this time.
0 commit comments