@@ -4177,22 +4177,20 @@ object Types {
4177
4177
case nil => x
4178
4178
foldArgs(op(x, tycon), args)
4179
4179
4180
- override def tryNormalize (using Context ): Type = tycon.stripTypeVar match {
4181
- case tycon : TypeRef =>
4182
- def tryMatchAlias = tycon.info match {
4183
- case MatchAlias (alias) =>
4184
- trace(i " normalize $this" , typr, show = true ) {
4185
- MatchTypeTrace .recurseWith(this ) {
4186
- alias.applyIfParameterized(args.map(_.normalized)).tryNormalize
4180
+ override def tryNormalize (using Context ): Type =
4181
+ tycon.stripTypeVar match
4182
+ case tycon : TypeRef =>
4183
+ def tryMatchAlias = tycon.info match
4184
+ case MatchAlias (alias) =>
4185
+ trace(i " normalize $this" , typr, show = true ) {
4186
+ MatchTypeTrace .recurseWith(this ) {
4187
+ alias.applyIfParameterized(args.map(_.normalized)).tryNormalize
4188
+ }
4187
4189
}
4188
- }
4189
- case _ =>
4190
- NoType
4191
- }
4192
- tryCompiletimeConstantFold.orElse(tryMatchAlias)
4193
- case _ =>
4194
- NoType
4195
- }
4190
+ case _ => NoType
4191
+ tryCompiletimeConstantFold.orElse(tryMatchAlias)
4192
+ case _ =>
4193
+ NoType
4196
4194
4197
4195
/** Does this application expand to a match type? */
4198
4196
def isMatchAlias (using Context ): Boolean = tycon.stripTypeVar match
@@ -4212,7 +4210,16 @@ object Types {
4212
4210
def isUnreducibleWild (using Context ): Boolean =
4213
4211
tycon.isLambdaSub && hasWildcardArg && ! isMatchAlias
4214
4212
4215
- def tryCompiletimeConstantFold (using Context ): Type = tycon match {
4213
+ var myTryCompiletimeConstantFold : Type | Null = null
4214
+ var myTryCompiletimeConstantFoldPeriod : Period = Nowhere
4215
+
4216
+ def tryCompiletimeConstantFold (using Context ): Type =
4217
+ if myTryCompiletimeConstantFoldPeriod != ctx.period then
4218
+ myTryCompiletimeConstantFoldPeriod = ctx.period
4219
+ myTryCompiletimeConstantFold = tryCompiletimeConstantFoldImpl
4220
+ myTryCompiletimeConstantFold.nn
4221
+
4222
+ private def tryCompiletimeConstantFoldImpl (using Context ): Type = tycon match {
4216
4223
case tycon : TypeRef if defn.isCompiletimeAppliedType(tycon.symbol) =>
4217
4224
extension (tp : Type ) def fixForEvaluation : Type =
4218
4225
tp.normalized.dealias match {
0 commit comments