@@ -468,11 +468,6 @@ object Types extends TypeUtils {
468
468
/** Does this application expand to a match type? */
469
469
def isMatchAlias (using Context ): Boolean = underlyingNormalizable.isMatch
470
470
471
- def underlyingNormalizable (using Context ): Type = stripped.stripLazyRef match
472
- case tp : MatchType => tp
473
- case tp : AppliedType => tp.underlyingNormalizable
474
- case _ => NoType
475
-
476
471
/** Is this a higher-kinded type lambda with given parameter variances?
477
472
* These lambdas are used as the RHS of higher-kinded abstract types or
478
473
* type aliases. The variance info is strictly needed only for abstract types.
@@ -1524,22 +1519,25 @@ object Types extends TypeUtils {
1524
1519
}
1525
1520
deskolemizer(this )
1526
1521
1527
- /** The result of normalization using `tryNormalize`, or the type itself if
1528
- * tryNormlize yields NoType
1529
- */
1530
- final def normalized (using Context ): Type = {
1531
- val normed = tryNormalize
1532
- if (normed.exists) normed else this
1533
- }
1522
+ /** The result of normalization, or the type itself if none apply. */
1523
+ final def normalized (using Context ): Type = tryNormalize.orElse(this )
1534
1524
1535
1525
/** If this type has an underlying match type or applied compiletime.ops,
1536
1526
* then the result after applying all toplevel normalizations, otherwise NoType.
1537
1527
*/
1538
1528
def tryNormalize (using Context ): Type = underlyingNormalizable match
1539
- case mt : MatchType => mt.tryNormalize
1529
+ case mt : MatchType => mt.reduced.normalized
1540
1530
case tp : AppliedType => tp.tryCompiletimeConstantFold
1541
1531
case _ => NoType
1542
1532
1533
+ /** Perform successive strippings, and beta-reductions of applied types until
1534
+ * a match type or applied compiletime.ops is reached, if any, otherwise NoType.
1535
+ */
1536
+ def underlyingNormalizable (using Context ): Type = stripped.stripLazyRef match
1537
+ case tp : MatchType => tp
1538
+ case tp : AppliedType => tp.underlyingNormalizable
1539
+ case _ => NoType
1540
+
1543
1541
private def widenDealias1 (keep : AnnotatedType => Context ?=> Boolean )(using Context ): Type = {
1544
1542
val res = this .widen.dealias1(keep, keepOpaques = false )
1545
1543
if (res eq this ) res else res.widenDealias1(keep)
@@ -4643,9 +4641,10 @@ object Types extends TypeUtils {
4643
4641
case nil => x
4644
4642
foldArgs(op(x, tycon), args)
4645
4643
4646
- /** Exists if the tycon is a TypeRef of an alias with an underlying match type.
4647
- * Anything else should have already been reduced in `appliedTo` by the TypeAssigner.
4648
- * May reduce several HKTypeLambda applications before the underlying MatchType is reached.
4644
+ /** Exists if the tycon is a TypeRef of an alias with an underlying match type,
4645
+ * or a compiletime applied type. Anything else should have already been
4646
+ * reduced in `appliedTo` by the TypeAssigner. This may reduce several
4647
+ * HKTypeLambda applications before the underlying normalizable type is reached.
4649
4648
*/
4650
4649
override def underlyingNormalizable (using Context ): Type =
4651
4650
if ctx.period != validUnderlyingNormalizable then
@@ -5085,9 +5084,6 @@ object Types extends TypeUtils {
5085
5084
private var myReduced : Type | Null = null
5086
5085
private var reductionContext : util.MutableMap [Type , Type ] | Null = null
5087
5086
5088
- override def tryNormalize (using Context ): Type =
5089
- reduced.normalized
5090
-
5091
5087
private def thisMatchType = this
5092
5088
5093
5089
def reduced (using Context ): Type = atPhaseNoLater(elimOpaquePhase) {
0 commit comments