Skip to content

Commit 739a310

Browse files
committed
Fix crash reporter, units and phases
1 parent d0b790e commit 739a310

File tree

4 files changed

+9
-13
lines changed

4 files changed

+9
-13
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
308308

309309
private def printTree(last: PrintedTree)(using Context): PrintedTree = {
310310
val unit = ctx.compilationUnit
311-
val fusedPhase = ctx.phase.prevMega
311+
val fusedPhase = ctx.phase.prev.megaPhase
312312
val echoHeader = f"[[syntax trees at end of $fusedPhase%25s]] // ${unit.source}"
313313
val tree = if ctx.isAfterTyper then unit.tpdTree else unit.untpdTree
314314
val treeString = fusedPhase.show(tree)

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,9 @@ object Phases {
321321
def run(using Context): Unit
322322

323323
/** @pre `isRunnable` returns true */
324-
def runOn(units: List[CompilationUnit])(using Context): List[CompilationUnit] =
324+
def runOn(units: List[CompilationUnit])(using runCtx: Context): List[CompilationUnit] =
325325
units.map { unit =>
326-
val unitCtx = ctx.fresh.setPhase(this.start).setCompilationUnit(unit).withRootImports
326+
given unitCtx: Context = runCtx.fresh.setPhase(this.start).setCompilationUnit(unit).withRootImports
327327
try run(using unitCtx)
328328
catch case ex: Throwable if !ctx.run.enrichedErrorMessage =>
329329
println(ctx.run.enrichErrorMessage(s"unhandled exception while running $phaseName on $unit"))
@@ -425,8 +425,8 @@ object Phases {
425425
final def prev: Phase =
426426
if (id > FirstPhaseId) myBase.phases(start - 1) else NoPhase
427427

428-
final def prevMega(using Context): Phase =
429-
ctx.base.fusedContaining(ctx.phase.prev)
428+
final def megaPhase(using Context): Phase =
429+
ctx.base.fusedContaining(ctx.phase)
430430

431431
final def next: Phase =
432432
if (hasNext) myBase.phases(end + 1) else NoPhase
@@ -439,8 +439,8 @@ object Phases {
439439
final def monitor(doing: String)(body: => Unit)(using Context): Unit =
440440
try body
441441
catch
442-
case NonFatal(ex) =>
443-
report.echo(s"exception occurred while $doing ${ctx.compilationUnit}")
442+
case NonFatal(ex) if !ctx.run.enrichedErrorMessage =>
443+
report.echo(ctx.run.enrichErrorMessage(s"exception occurred while $doing ${ctx.compilationUnit}"))
444444
throw ex
445445

446446
override def toString: String = phaseName

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ object report:
151151

152152
val info1 = formatExplain(List(
153153
"while compiling" -> ctx.compilationUnit,
154-
"during phase" -> ctx.phase.prevMega,
154+
"during phase" -> ctx.phase.megaPhase,
155155
"mode" -> ctx.mode,
156156
"library version" -> scala.util.Properties.versionString,
157157
"compiler version" -> dotty.tools.dotc.config.Properties.versionString,

compiler/src/dotty/tools/dotc/typer/TyperPhase.scala

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,7 @@ class TyperPhase(addRootImports: Boolean = true) extends Phase {
4646
record("retained untyped trees", unit.untpdTree.treeSize)
4747
record("retained typed trees after typer", unit.tpdTree.treeSize)
4848
ctx.run.nn.suppressions.reportSuspendedMessages(unit.source)
49-
catch
50-
case ex: CompilationUnit.SuspendException =>
51-
case ex: Throwable =>
52-
println(s"$ex while typechecking $unit")
53-
throw ex
49+
catch case _: CompilationUnit.SuspendException => ()
5450
}
5551

5652
def javaCheck(using Context): Unit = monitor("checking java") {

0 commit comments

Comments
 (0)