@@ -452,13 +452,18 @@ object Types extends TypeUtils {
452452 /** Is this a MethodType for which the parameters will not be used? */
453453 def hasErasedParams (using Context ): Boolean = false
454454
455- /** Is this a match type or a higher-kinded abstraction of one?
456- */
457- def isMatch (using Context ): Boolean = underlyingMatchType.exists
455+ /** Is this a match type or a higher-kinded abstraction of one? */
456+ def isMatch (using Context ): Boolean = stripped match
457+ case tp : MatchType => true
458+ case tp : HKTypeLambda => tp.resType.isMatch
459+ case _ => false
460+
461+ /** Does this application expand to a match type? */
462+ def isMatchAlias (using Context ): Boolean = underlyingNormalizable.isMatch
458463
459- def underlyingMatchType (using Context ): Type = stripped match
464+ def underlyingNormalizable (using Context ): Type = stripped match
460465 case tp : MatchType => tp
461- case tp : AppliedType => tp.underlyingMatchType
466+ case tp : AppliedType => tp.underlyingNormalizable
462467 case _ => NoType
463468
464469 /** Is this a higher-kinded type lambda with given parameter variances?
@@ -4453,8 +4458,8 @@ object Types extends TypeUtils {
44534458 private var myEvalRunId : RunId = NoRunId
44544459 private var myEvalued : Type = uninitialized
44554460
4456- private var validUnderlyingMatch : Period = Nowhere
4457- private var cachedUnderlyingMatch : Type = uninitialized
4461+ private var validUnderlyingNormalizable : Period = Nowhere
4462+ private var cachedUnderlyingNormalizable : Type = uninitialized
44584463
44594464 def isGround (acc : TypeAccumulator [Boolean ])(using Context ): Boolean =
44604465 if myGround == 0 then myGround = if acc.foldOver(true , this ) then 1 else - 1
@@ -4516,30 +4521,26 @@ object Types extends TypeUtils {
45164521 * Anything else should have already been reduced in `appliedTo` by the TypeAssigner.
45174522 * May reduce several HKTypeLambda applications before the underlying MatchType is reached.
45184523 */
4519- override def underlyingMatchType (using Context ): Type =
4520- if ctx.period != validUnderlyingMatch then
4521- cachedUnderlyingMatch = superType.underlyingMatchType
4522- validUnderlyingMatch = validSuper
4523- cachedUnderlyingMatch
4524+ override def underlyingNormalizable (using Context ): Type =
4525+ if ctx.period != validUnderlyingNormalizable then tycon match
4526+ case tycon : TypeRef if defn.isCompiletimeAppliedType(tycon.symbol) =>
4527+ cachedUnderlyingNormalizable = this
4528+ validUnderlyingNormalizable = ctx.period
4529+ case _ =>
4530+ cachedUnderlyingNormalizable = superType.underlyingNormalizable
4531+ validUnderlyingNormalizable = validSuper
4532+ cachedUnderlyingNormalizable
45244533
45254534 override def tryNormalize (using Context ): Type =
45264535 def tryMatchAlias =
45274536 if isMatchAlias then trace(i " normalize $this" , typr, show = true ):
45284537 if MatchTypeTrace .isRecording then
45294538 MatchTypeTrace .recurseWith(this )(superType.tryNormalize)
45304539 else
4531- underlyingMatchType .tryNormalize
4540+ underlyingNormalizable .tryNormalize
45324541 else NoType
45334542 tryCompiletimeConstantFold.orElse(tryMatchAlias)
45344543
4535- /** Does this application expand to a match type? */
4536- def isMatchAlias (using Context ): Boolean = tycon.stripTypeVar match
4537- case tycon : TypeRef =>
4538- tycon.info match
4539- case _ : MatchAlias => true
4540- case _ => false
4541- case _ => false
4542-
45434544 /** Is this an unreducible application to wildcard arguments?
45444545 * This is the case if tycon is higher-kinded. This means
45454546 * it is a subtype of a hk-lambda, but not a match alias.
@@ -5041,10 +5042,9 @@ object Types extends TypeUtils {
50415042 def apply (bound : Type , scrutinee : Type , cases : List [Type ])(using Context ): MatchType =
50425043 unique(new CachedMatchType (bound, scrutinee, cases))
50435044
5044- def thatReducesUsingGadt (tp : Type )(using Context ): Boolean = tp match
5045- case MatchType .InDisguise (mt) => mt.reducesUsingGadt
5046- case mt : MatchType => mt.reducesUsingGadt
5047- case _ => false
5045+ def thatReducesUsingGadt (tp : Type )(using Context ): Boolean = tp.underlyingNormalizable match
5046+ case mt : MatchType => mt.reducesUsingGadt
5047+ case _ => false
50485048
50495049 /** Extractor for match types hidden behind an AppliedType/MatchAlias. */
50505050 object InDisguise :
0 commit comments