Skip to content

Commit 06bc8d5

Browse files
committed
Cache AppliedType#tryNormalize
1 parent 8d3083b commit 06bc8d5

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4177,22 +4177,25 @@ object Types {
41774177
case nil => x
41784178
foldArgs(op(x, tycon), args)
41794179

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
4187-
}
4188-
}
4180+
var myTryNormalize: Type | Null = null
4181+
var myTryNoramlizePeriod: Period = Nowhere
4182+
4183+
override def tryNormalize(using Context): Type =
4184+
if myTryNoramlizePeriod != ctx.period then
4185+
myTryNormalize = tycon.stripTypeVar match
4186+
case tycon: TypeRef =>
4187+
def tryMatchAlias = tycon.info match
4188+
case MatchAlias(alias) =>
4189+
trace(i"normalize $this", typr, show = true) {
4190+
MatchTypeTrace.recurseWith(this) {
4191+
alias.applyIfParameterized(args.map(_.normalized)).tryNormalize
4192+
}
4193+
}
4194+
case _ => NoType
4195+
tryCompiletimeConstantFold.orElse(tryMatchAlias)
41894196
case _ =>
41904197
NoType
4191-
}
4192-
tryCompiletimeConstantFold.orElse(tryMatchAlias)
4193-
case _ =>
4194-
NoType
4195-
}
4198+
myTryNormalize.nn
41964199

41974200
/** Does this application expand to a match type? */
41984201
def isMatchAlias(using Context): Boolean = tycon.stripTypeVar match

0 commit comments

Comments
 (0)