@@ -680,11 +680,8 @@ object Contexts {
680680 final def retractMode (mode : Mode ): c.type = c.setMode(c.mode &~ mode)
681681 }
682682
683- /** Test `op` in a fresh context with a typerstate that is not committable.
684- * The passed context may not survive the operation.
685- */
686- def explore [T ](op : Context ?=> T )(using Context ): T =
687- util.Stats .record(" Context.test" )
683+ private def exploreCtx (using Context ): Context =
684+ util.Stats .record(" explore" )
688685 val base = ctx.base
689686 import base ._
690687 val nestedCtx =
@@ -700,13 +697,15 @@ object Contexts {
700697 exploresInUse += 1
701698 val nestedTS = nestedCtx.typerState
702699 nestedTS.init(ctx.typerState, ctx.typerState.constraint)
703- val result =
704- try op(using nestedCtx)
705- finally
706- nestedTS.reporter.asInstanceOf [ExploringReporter ].reset()
707- exploresInUse -= 1
708- result
709- end explore
700+ nestedCtx
701+
702+ private def wrapUpExplore (ectx : Context ) =
703+ ectx.reporter.asInstanceOf [ExploringReporter ].reset()
704+ ectx.base.exploresInUse -= 1
705+
706+ inline def explore [T ](inline op : Context ?=> T )(using Context ): T =
707+ val ectx = exploreCtx
708+ try op(using ectx) finally wrapUpExplore(ectx)
710709
711710 /** The type comparer of the kind created by `maker` to be used.
712711 * This is the currently active type comparer CMP if
@@ -716,6 +715,7 @@ object Contexts {
716715 * In other words: tracking or explaining is a sticky property in the same context.
717716 */
718717 private def comparer (using Context ): TypeComparer =
718+ util.Stats .record(" comparing" )
719719 val base = ctx.base
720720 if base.comparersInUse > 0
721721 && (base.comparers(base.comparersInUse - 1 ).comparerContext eq ctx)
0 commit comments