@@ -172,30 +172,30 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
172
172
private var _progress : Progress | Null = null // Set if progress reporting is enabled
173
173
174
174
/** Only safe to call if progress is being tracked. */
175
- private inline def trackProgress (using Context )( inline op : Context ?=> Progress => Unit ): Unit =
175
+ private inline def trackProgress (inline op : Progress => Unit ): Unit =
176
176
val local = _progress
177
177
if local != null then
178
- op(using ctx)( local)
178
+ op(local)
179
179
180
- private inline def foldProgress [T ](using Context )( inline default : T )(inline op : Context ?=> Progress => T ): T =
180
+ private inline def foldProgress [T ](inline default : T )(inline op : Progress => T ): T =
181
181
val local = _progress
182
182
if local != null then
183
- op(using ctx)( local)
183
+ op(local)
184
184
else
185
185
default
186
186
187
- def didEnterUnit ()( using Context ): Boolean =
188
- foldProgress(true /* should progress by default */ )(_.tryEnterUnit(ctx.compilationUnit ))
187
+ def didEnterUnit (unit : CompilationUnit ): Boolean =
188
+ foldProgress(true /* should progress by default */ )(_.tryEnterUnit(unit ))
189
189
190
- def didEnterFinal ()( using Context ): Boolean =
191
- foldProgress(true /* should progress by default */ )(p => ! p .checkCancellation())
190
+ def progressCancelled ( ): Boolean =
191
+ foldProgress(false /* should progress by default */ )(_ .checkCancellation())
192
192
193
- def doAdvanceUnit ()( using Context ) : Unit =
193
+ def doAdvanceUnit (): Unit =
194
194
trackProgress : progress =>
195
195
progress.unitc += 1 // trace that we completed a unit in the current (sub)phase
196
196
progress.refreshProgress()
197
197
198
- def doAdvanceLate ()( using Context ) : Unit =
198
+ def doAdvanceLate (): Unit =
199
199
trackProgress : progress =>
200
200
progress.latec += 1 // trace that we completed a late compilation
201
201
progress.refreshProgress()
@@ -211,7 +211,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
211
211
finally
212
212
Thread .currentThread().nn.interrupt()
213
213
214
- private def doAdvancePhase (currentPhase : Phase , wasRan : Boolean )( using Context ) : Unit =
214
+ private def doAdvancePhase (currentPhase : Phase , wasRan : Boolean ): Unit =
215
215
trackProgress : progress =>
216
216
progress.unitc = 0 // reset unit count in current (sub)phase
217
217
progress.subtraversalc = 0 // reset subphase index to initial
@@ -223,7 +223,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
223
223
// no subphases were ran, remove traversals from expected total
224
224
progress.totalTraversals -= currentPhase.traversals
225
225
226
- private def doAdvanceSubPhase ()(using Context ): Unit =
226
+ private def doEnterSubPhase ()(using Context ): Unit =
227
227
trackProgress : progress =>
228
228
progress.unitc = 0 // reset unit count in current (sub)phase
229
229
progress.seen += 1 // trace that we've seen a (sub)phase
@@ -351,7 +351,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
351
351
if (! ctx.reporter.hasErrors)
352
352
Rewrites .writeBack()
353
353
suppressions.runFinished(hasErrors = ctx.reporter.hasErrors)
354
- while (finalizeActions.nonEmpty && didEnterFinal ()) {
354
+ while (finalizeActions.nonEmpty && ! progressCancelled ()) {
355
355
val action = finalizeActions.remove(0 )
356
356
action()
357
357
}
@@ -563,7 +563,7 @@ object Run {
563
563
true
564
564
565
565
/** trace the current progress out of the total, in the current (sub)phase, reporting the next (sub)phase */
566
- private [Run ] def refreshProgress ()( using Context ) : Unit =
566
+ private [Run ] def refreshProgress (): Unit =
567
567
requireInitialized()
568
568
val total = totalProgress()
569
569
if total > 0 && ! cb.progress(currentProgress(), total, currPhaseName, nextPhaseName) then
@@ -572,19 +572,25 @@ object Run {
572
572
extension (run : Run | Null )
573
573
574
574
/** record that the current phase has begun for the compilation unit of the current Context */
575
- def enterUnit ()(using Context ): Boolean =
576
- if run != null then run.didEnterUnit()
575
+ def enterUnit (unit : CompilationUnit ): Boolean =
576
+ if run != null then run.didEnterUnit(unit)
577
+ else true // don't check cancellation if we're not tracking progress
578
+
579
+ /** check progress cancellation, true if not cancelled */
580
+ def enterBlock (): Boolean =
581
+ if run != null then ! run.progressCancelled()
577
582
else true // don't check cancellation if we're not tracking progress
578
583
579
584
/** advance the unit count and record progress in the current phase */
580
- def advanceUnit ()( using Context ) : Unit =
585
+ def advanceUnit (): Unit =
581
586
if run != null then run.doAdvanceUnit()
582
587
583
- def advanceSubPhase ()(using Context ): Unit =
584
- if run != null then run.doAdvanceSubPhase()
588
+ /** advance the current/next sub-phase and record progress */
589
+ def enterSubPhase ()(using Context ): Unit =
590
+ if run != null then run.doEnterSubPhase()
585
591
586
592
/** advance the late count and record progress in the current phase */
587
- def advanceLate ()( using Context ) : Unit =
593
+ def advanceLate (): Unit =
588
594
if run != null then run.doAdvanceLate()
589
595
590
596
def enrichedErrorMessage : Boolean = if run == null then false else run.myEnrichedErrorMessage
0 commit comments