@@ -74,12 +74,12 @@ object Contexts {
74
74
75
75
/** Execute `op` at given period */
76
76
inline def atPeriod [T ](period : Period )(inline op : (Ctx , CState ) ?=> T )(using Ctx , CState ): T =
77
- op(using ctx.fresh.setPeriod(period) , period)
77
+ op(using ctx, period)
78
78
79
79
/** Execute `op` at given phase id */
80
80
inline def atPhase [T ](pid : PhaseId )(inline op : (Ctx , CState ) ?=> T )(using Ctx , CState ): T =
81
- op(using
82
- if pid == currentPhaseId then ctx else ctx.withPhase(pid),
81
+ op(using ctx,
82
+ // if pid == currentPhaseId then ctx else ctx.withPhase(pid),
83
83
if pid == currentPhaseId then currentPeriod else Period (currentRunId, pid))
84
84
85
85
/** Execute `op` at given phase */
@@ -140,7 +140,7 @@ object Contexts {
140
140
def importInfo : ImportInfo
141
141
def gadt : GadtConstraint
142
142
def searchHistory : SearchHistory
143
- def typeComparer : TypeComparer
143
+ def typeComparer ( using CState ) : TypeComparer
144
144
def source : SourceFile
145
145
def moreProperties : Map [Key [Any ], Any ]
146
146
def property [T ](key : Key [T ]): Option [T ]
@@ -178,6 +178,7 @@ object Contexts {
178
178
def withPeriod (pd : Period ): Context
179
179
def withPhase (phaseId : PhaseId ): Context
180
180
def withPhase (phase : Phase ): Context
181
+ def withPhaseNoLater (phase : Phase ): Context
181
182
def withOwner (owner : Symbol ): Ctx
182
183
def withSource (source : SourceFile ): Ctx
183
184
def withProperty [T ](key : Key [T ], value : Option [T ]): Ctx
@@ -321,9 +322,10 @@ object Contexts {
321
322
*/
322
323
private var _typeComparer : TypeComparer = _
323
324
protected def typeComparer_= (typeComparer : TypeComparer ): Unit = _typeComparer = typeComparer
324
- def typeComparer : TypeComparer = {
325
+ def typeComparer ( using CState ) : TypeComparer = {
325
326
if (_typeComparer.comparerCtx ne this )
326
327
_typeComparer = _typeComparer.copyIn(this )
328
+ _typeComparer.initCState = currentPeriod
327
329
_typeComparer
328
330
}
329
331
@@ -434,14 +436,6 @@ object Contexts {
434
436
/** Sourcefile with given path, memoized */
435
437
def getSource (path : String ): SourceFile = getSource(path.toTermName)
436
438
437
- /** Those fields are used to cache phases created in withPhase.
438
- * phasedCtx is first phase with altered phase ever requested.
439
- * phasedCtxs is array that uses phaseId's as indexes,
440
- * contexts are created only on request and cached in this array
441
- */
442
- private var phasedCtx : Context = this
443
- private var phasedCtxs : Array [Context ] = null
444
-
445
439
def withPeriod (pd : Period ): Context =
446
440
if period == pd then this else fresh.setPeriod(pd)
447
441
@@ -450,17 +444,7 @@ object Contexts {
450
444
*/
451
445
final def withPhase (phaseId : PhaseId ): Context =
452
446
if (this .period.phaseId == phaseId) this
453
- else if (phasedCtx.period.phaseId == phaseId) phasedCtx
454
- else if (phasedCtxs != null && phasedCtxs(phaseId) != null ) phasedCtxs(phaseId)
455
- else {
456
- val ctx1 = fresh.setPhase(phaseId)
457
- if (phasedCtx eq this ) phasedCtx = ctx1
458
- else {
459
- if (phasedCtxs == null ) phasedCtxs = new Array [Context ](base.phases.length)
460
- phasedCtxs(phaseId) = ctx1
461
- }
462
- ctx1
463
- }
447
+ else fresh.setPhase(phaseId)
464
448
465
449
final def withPhase (phase : Phase ): Context =
466
450
withPhase(phase.id)
@@ -554,11 +538,10 @@ object Contexts {
554
538
this
555
539
}
556
540
557
- def reuseIn (outer : Context ): this .type =
541
+ def reuseIn (outer : Ctx )( using CState ): this .type =
558
542
implicitsCache = null
559
- phasedCtxs = null
560
543
sourceCtx = null
561
- init(outer, outer)
544
+ init(outer, outer, currentPeriod )
562
545
563
546
/** A fresh clone of this context embedded in this context. */
564
547
def fresh : FreshContext = freshOver(this )
@@ -767,7 +750,7 @@ object Contexts {
767
750
import base ._
768
751
val nestedCtx =
769
752
if testsInUse < testContexts.size then
770
- testContexts(testsInUse).reuseIn(ctx.toContextUNSAFE )
753
+ testContexts(testsInUse).reuseIn(ctx)
771
754
else
772
755
val ts = TyperState ()
773
756
.setReporter(TestingReporter ())
0 commit comments