@@ -321,10 +321,10 @@ 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
327- try run( using unitCtx)
326+ given unitCtx : Context = runCtx .fresh.setPhase(this .start).setCompilationUnit(unit).withRootImports
327+ try run
328328 catch case ex : Throwable if ! ctx.run.enrichedErrorMessage =>
329329 println(ctx.run.enrichErrorMessage(s " unhandled exception while running $phaseName on $unit" ))
330330 throw ex
@@ -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(this )
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
0 commit comments