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