@@ -491,12 +491,10 @@ object Types extends TypeUtils {
491491 /** Does this application expand to a match type? */
492492 def isMatchAlias (using Context ): Boolean = underlyingMatchType.exists
493493
494- def underlyingMatchType (using Context ): Type = stripped match {
494+ def underlyingMatchType (using Context ): Type = stripped match
495495 case tp : MatchType => tp
496- case tp : HKTypeLambda => tp.resType.underlyingMatchType
497496 case tp : AppliedType => tp.underlyingMatchType
498497 case _ => NoType
499- }
500498
501499 /** Is this a higher-kinded type lambda with given parameter variances?
502500 * These lambdas are used as the RHS of higher-kinded abstract types or
@@ -4681,35 +4679,23 @@ object Types extends TypeUtils {
46814679
46824680 /** Exists if the tycon is a TypeRef of an alias with an underlying match type.
46834681 * Anything else should have already been reduced in `appliedTo` by the TypeAssigner.
4682+ * May reduce several HKTypeLambda applications before the underlying MatchType is reached.
46844683 */
46854684 override def underlyingMatchType (using Context ): Type =
46864685 if ctx.period != validUnderlyingMatch then
46874686 cachedUnderlyingMatch = superType.underlyingMatchType
46884687 validUnderlyingMatch = validSuper
46894688 cachedUnderlyingMatch
46904689
4691- override def tryNormalize (using Context ): Type = tycon.stripTypeVar match {
4692- case tycon : TypeRef =>
4693- def tryMatchAlias = tycon.info match
4694- case AliasingBounds (alias) if isMatchAlias =>
4695- trace(i " normalize $this" , typr, show = true ) {
4696- MatchTypeTrace .recurseWith(this ) {
4697- alias.applyIfParameterized(args).tryNormalize
4698- /* `applyIfParameterized` may reduce several HKTypeLambda applications
4699- * before the underlying MatchType is reached.
4700- * Even if they do not involve any match type normalizations yet,
4701- * we still want to record these reductions in the MatchTypeTrace.
4702- * They should however only be attempted if they eventually expand
4703- * to a match type, which is ensured by the `isMatchAlias` guard.
4704- */
4705- }
4706- }
4707- case _ =>
4708- NoType
4709- tryCompiletimeConstantFold.orElse(tryMatchAlias)
4710- case _ =>
4711- NoType
4712- }
4690+ override def tryNormalize (using Context ): Type =
4691+ def tryMatchAlias =
4692+ if isMatchAlias then trace(i " normalize $this" , typr, show = true ):
4693+ if MatchTypeTrace .isRecording then
4694+ MatchTypeTrace .recurseWith(this )(superType.tryNormalize)
4695+ else
4696+ underlyingMatchType.tryNormalize
4697+ else NoType
4698+ tryCompiletimeConstantFold.orElse(tryMatchAlias)
47134699
47144700 /** Is this an unreducible application to wildcard arguments?
47154701 * This is the case if tycon is higher-kinded. This means
0 commit comments