Skip to content

Commit eeca5f1

Browse files
committed
Fix incorrect use of phase.prev, introduce prevMega
1 parent 20edebe commit eeca5f1

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

compiler/src/dotty/tools/dotc/Run.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
282282

283283
private def printTree(last: PrintedTree)(using Context): PrintedTree = {
284284
val unit = ctx.compilationUnit
285-
val prevPhase = ctx.phase.prev // can be a mini-phase
286-
val fusedPhase = ctx.base.fusedContaining(prevPhase)
285+
val fusedPhase = ctx.phase.prevMega
287286
val echoHeader = f"[[syntax trees at end of $fusedPhase%25s]] // ${unit.source}"
288287
val tree = if ctx.isAfterTyper then unit.tpdTree else unit.untpdTree
289288
val treeString = tree.show(using ctx.withProperty(XprintMode, Some(())))

compiler/src/dotty/tools/dotc/core/Phases.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,9 @@ object Phases {
402402
final def prev: Phase =
403403
if (id > FirstPhaseId) myBase.phases(start - 1) else NoPhase
404404

405+
final def prevMega(using Context): Phase =
406+
ctx.base.fusedContaining(ctx.phase.prev)
407+
405408
final def next: Phase =
406409
if (hasNext) myBase.phases(end + 1) else NoPhase
407410

compiler/src/dotty/tools/dotc/transform/TreeChecker.scala

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class TreeChecker extends Phase with SymTransformer {
9191
if (ctx.phaseId <= erasurePhase.id) {
9292
val initial = symd.initial
9393
assert(symd == initial || symd.signature == initial.signature,
94-
i"""Signature of ${sym.showLocated} changed at phase ${ctx.base.fusedContaining(ctx.phase.prev)}
94+
i"""Signature of ${sym.showLocated} changed at phase ${ctx.phase.prevMega}
9595
|Initial info: ${initial.info}
9696
|Initial sig : ${initial.signature}
9797
|Current info: ${symd.info}
@@ -122,8 +122,7 @@ class TreeChecker extends Phase with SymTransformer {
122122
}
123123

124124
def check(phasesToRun: Seq[Phase], ctx: Context): Tree = {
125-
val prevPhase = ctx.phase.prev // can be a mini-phase
126-
val fusedPhase = ctx.base.fusedContaining(prevPhase)
125+
val fusedPhase = ctx.phase.prevMega(using ctx)
127126
report.echo(s"checking ${ctx.compilationUnit} after phase ${fusedPhase}")(using ctx)
128127

129128
inContext(ctx) {
@@ -145,7 +144,7 @@ class TreeChecker extends Phase with SymTransformer {
145144
catch {
146145
case NonFatal(ex) => //TODO CHECK. Check that we are bootstrapped
147146
inContext(checkingCtx) {
148-
println(i"*** error while checking ${ctx.compilationUnit} after phase ${ctx.phase.prev} ***")
147+
println(i"*** error while checking ${ctx.compilationUnit} after phase ${ctx.phase.prevMega(using ctx)} ***")
149148
}
150149
throw ex
151150
}

0 commit comments

Comments
 (0)