File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
compiler/src/dotty/tools/dotc/core Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -4169,6 +4169,9 @@ object Types {
41694169 private var myisStableRunId : RunId = NoRunId
41704170 private var myIsStable : Boolean = uninitialized
41714171
4172+ private var myEvalRunId : RunId = NoRunId
4173+ private var myEvalued : Type = uninitialized
4174+
41724175 def isGround (acc : TypeAccumulator [Boolean ])(using Context ): Boolean =
41734176 if myGround == 0 then myGround = if acc.foldOver(true , this ) then 1 else - 1
41744177 myGround > 0
@@ -4278,7 +4281,17 @@ object Types {
42784281 def isUnreducibleWild (using Context ): Boolean =
42794282 tycon.isLambdaSub && hasWildcardArg && ! isMatchAlias
42804283
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 {
42824295 case tycon : TypeRef if defn.isCompiletimeAppliedType(tycon.symbol) =>
42834296 extension (tp : Type ) def fixForEvaluation : Type =
42844297 tp.normalized.dealias match {
You can’t perform that action at this time.
0 commit comments