@@ -680,11 +680,8 @@ object Contexts {
680
680
final def retractMode (mode : Mode ): c.type = c.setMode(c.mode &~ mode)
681
681
}
682
682
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" )
688
685
val base = ctx.base
689
686
import base ._
690
687
val nestedCtx =
@@ -700,13 +697,15 @@ object Contexts {
700
697
exploresInUse += 1
701
698
val nestedTS = nestedCtx.typerState
702
699
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)
710
709
711
710
/** The type comparer of the kind created by `maker` to be used.
712
711
* This is the currently active type comparer CMP if
@@ -716,6 +715,7 @@ object Contexts {
716
715
* In other words: tracking or explaining is a sticky property in the same context.
717
716
*/
718
717
private def comparer (using Context ): TypeComparer =
718
+ util.Stats .record(" comparing" )
719
719
val base = ctx.base
720
720
if base.comparersInUse > 0
721
721
&& (base.comparers(base.comparersInUse - 1 ).comparerContext eq ctx)
0 commit comments