@@ -491,11 +491,6 @@ object Types extends TypeUtils {
491
491
/** Does this application expand to a match type? */
492
492
def isMatchAlias (using Context ): Boolean = underlyingNormalizable.isMatch
493
493
494
- def underlyingNormalizable (using Context ): Type = stripped.stripLazyRef match
495
- case tp : MatchType => tp
496
- case tp : AppliedType => tp.underlyingNormalizable
497
- case _ => NoType
498
-
499
494
/** Is this a higher-kinded type lambda with given parameter variances?
500
495
* These lambdas are used as the RHS of higher-kinded abstract types or
501
496
* type aliases. The variance info is strictly needed only for abstract types.
@@ -1547,22 +1542,25 @@ object Types extends TypeUtils {
1547
1542
}
1548
1543
deskolemizer(this )
1549
1544
1550
- /** The result of normalization using `tryNormalize`, or the type itself if
1551
- * tryNormlize yields NoType
1552
- */
1553
- final def normalized (using Context ): Type = {
1554
- val normed = tryNormalize
1555
- if (normed.exists) normed else this
1556
- }
1545
+ /** The result of normalization, or the type itself if none apply. */
1546
+ final def normalized (using Context ): Type = tryNormalize.orElse(this )
1557
1547
1558
1548
/** If this type has an underlying match type or applied compiletime.ops,
1559
1549
* then the result after applying all toplevel normalizations, otherwise NoType.
1560
1550
*/
1561
1551
def tryNormalize (using Context ): Type = underlyingNormalizable match
1562
- case mt : MatchType => mt.tryNormalize
1552
+ case mt : MatchType => mt.reduced.normalized
1563
1553
case tp : AppliedType => tp.tryCompiletimeConstantFold
1564
1554
case _ => NoType
1565
1555
1556
+ /** Perform successive strippings, and beta-reductions of applied types until
1557
+ * a match type or applied compiletime.ops is reached, if any, otherwise NoType.
1558
+ */
1559
+ def underlyingNormalizable (using Context ): Type = stripped.stripLazyRef match
1560
+ case tp : MatchType => tp
1561
+ case tp : AppliedType => tp.underlyingNormalizable
1562
+ case _ => NoType
1563
+
1566
1564
private def widenDealias1 (keep : AnnotatedType => Context ?=> Boolean )(using Context ): Type = {
1567
1565
val res = this .widen.dealias1(keep, keepOpaques = false )
1568
1566
if (res eq this ) res else res.widenDealias1(keep)
@@ -4677,9 +4675,10 @@ object Types extends TypeUtils {
4677
4675
case nil => x
4678
4676
foldArgs(op(x, tycon), args)
4679
4677
4680
- /** Exists if the tycon is a TypeRef of an alias with an underlying match type.
4681
- * Anything else should have already been reduced in `appliedTo` by the TypeAssigner.
4682
- * May reduce several HKTypeLambda applications before the underlying MatchType is reached.
4678
+ /** Exists if the tycon is a TypeRef of an alias with an underlying match type,
4679
+ * or a compiletime applied type. Anything else should have already been
4680
+ * reduced in `appliedTo` by the TypeAssigner. This may reduce several
4681
+ * HKTypeLambda applications before the underlying normalizable type is reached.
4683
4682
*/
4684
4683
override def underlyingNormalizable (using Context ): Type =
4685
4684
if ctx.period != validUnderlyingNormalizable then tycon match
@@ -5157,9 +5156,6 @@ object Types extends TypeUtils {
5157
5156
private var myReduced : Type | Null = null
5158
5157
private var reductionContext : util.MutableMap [Type , Type ] | Null = null
5159
5158
5160
- override def tryNormalize (using Context ): Type =
5161
- reduced.normalized
5162
-
5163
5159
private def thisMatchType = this
5164
5160
5165
5161
def reduced (using Context ): Type = atPhaseNoLater(elimOpaquePhase) {
0 commit comments