File tree 1 file changed +14
-1
lines changed
compiler/src/dotty/tools/dotc/core
1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -4169,6 +4169,9 @@ object Types {
4169
4169
private var myisStableRunId : RunId = NoRunId
4170
4170
private var myIsStable : Boolean = uninitialized
4171
4171
4172
+ private var myEvalRunId : RunId = NoRunId
4173
+ private var myEvalued : Type = uninitialized
4174
+
4172
4175
def isGround (acc : TypeAccumulator [Boolean ])(using Context ): Boolean =
4173
4176
if myGround == 0 then myGround = if acc.foldOver(true , this ) then 1 else - 1
4174
4177
myGround > 0
@@ -4278,7 +4281,17 @@ object Types {
4278
4281
def isUnreducibleWild (using Context ): Boolean =
4279
4282
tycon.isLambdaSub && hasWildcardArg && ! isMatchAlias
4280
4283
4281
- def tryCompiletimeConstantFold (using Context ): Type = tycon match {
4284
+ def tryCompiletimeConstantFold (using Context ): Type =
4285
+ if myEvalRunId == ctx.runId then myEvalued
4286
+ else
4287
+ val res = tryCompiletimeConstantFold1
4288
+ if ! isProvisional then
4289
+ myEvalRunId = ctx.runId
4290
+ myEvalued = res
4291
+ res
4292
+
4293
+ // todo: move to separate module
4294
+ def tryCompiletimeConstantFold1 (using Context ): Type = tycon match {
4282
4295
case tycon : TypeRef if defn.isCompiletimeAppliedType(tycon.symbol) =>
4283
4296
extension (tp : Type ) def fixForEvaluation : Type =
4284
4297
tp.normalized.dealias match {
You can’t perform that action at this time.
0 commit comments