@@ -490,11 +490,11 @@ object Types extends TypeUtils {
490
490
case _ => false
491
491
492
492
/** Does this application expand to a match type? */
493
- def isMatchAlias (using Context ): Boolean = underlyingMatchType.exists
493
+ def isMatchAlias (using Context ): Boolean = underlyingNormalizable.isMatch
494
494
495
- def underlyingMatchType (using Context ): Type = stripped match
495
+ def underlyingNormalizable (using Context ): Type = stripped match
496
496
case tp : MatchType => tp
497
- case tp : AppliedType => tp.underlyingMatchType
497
+ case tp : AppliedType => tp.underlyingNormalizable
498
498
case _ => NoType
499
499
500
500
/** Is this a higher-kinded type lambda with given parameter variances?
@@ -4613,8 +4613,8 @@ object Types extends TypeUtils {
4613
4613
private var myEvalRunId : RunId = NoRunId
4614
4614
private var myEvalued : Type = uninitialized
4615
4615
4616
- private var validUnderlyingMatch : Period = Nowhere
4617
- private var cachedUnderlyingMatch : Type = uninitialized
4616
+ private var validUnderlyingNormalizable : Period = Nowhere
4617
+ private var cachedUnderlyingNormalizable : Type = uninitialized
4618
4618
4619
4619
def isGround (acc : TypeAccumulator [Boolean ])(using Context ): Boolean =
4620
4620
if myGround == 0 then myGround = if acc.foldOver(true , this ) then 1 else - 1
@@ -4682,19 +4682,23 @@ object Types extends TypeUtils {
4682
4682
* Anything else should have already been reduced in `appliedTo` by the TypeAssigner.
4683
4683
* May reduce several HKTypeLambda applications before the underlying MatchType is reached.
4684
4684
*/
4685
- override def underlyingMatchType (using Context ): Type =
4686
- if ctx.period != validUnderlyingMatch then
4687
- cachedUnderlyingMatch = superType.underlyingMatchType
4688
- validUnderlyingMatch = validSuper
4689
- cachedUnderlyingMatch
4685
+ override def underlyingNormalizable (using Context ): Type =
4686
+ if ctx.period != validUnderlyingNormalizable then tycon match
4687
+ case tycon : TypeRef if defn.isCompiletimeAppliedType(tycon.symbol) =>
4688
+ cachedUnderlyingNormalizable = this
4689
+ validUnderlyingNormalizable = ctx.period
4690
+ case _ =>
4691
+ cachedUnderlyingNormalizable = superType.underlyingNormalizable
4692
+ validUnderlyingNormalizable = validSuper
4693
+ cachedUnderlyingNormalizable
4690
4694
4691
4695
override def tryNormalize (using Context ): Type =
4692
4696
def tryMatchAlias =
4693
4697
if isMatchAlias then trace(i " normalize $this" , typr, show = true ):
4694
4698
if MatchTypeTrace .isRecording then
4695
4699
MatchTypeTrace .recurseWith(this )(superType.tryNormalize)
4696
4700
else
4697
- underlyingMatchType .tryNormalize
4701
+ underlyingNormalizable .tryNormalize
4698
4702
else NoType
4699
4703
tryCompiletimeConstantFold.orElse(tryMatchAlias)
4700
4704
@@ -5268,7 +5272,7 @@ object Types extends TypeUtils {
5268
5272
def apply (bound : Type , scrutinee : Type , cases : List [Type ])(using Context ): MatchType =
5269
5273
unique(new CachedMatchType (bound, scrutinee, cases))
5270
5274
5271
- def thatReducesUsingGadt (tp : Type )(using Context ): Boolean = tp.underlyingMatchType match
5275
+ def thatReducesUsingGadt (tp : Type )(using Context ): Boolean = tp.underlyingNormalizable match
5272
5276
case mt : MatchType => mt.reducesUsingGadt
5273
5277
case _ => false
5274
5278
0 commit comments