@@ -461,11 +461,6 @@ object Types extends TypeUtils {
461
461
/** Does this application expand to a match type? */
462
462
def isMatchAlias (using Context ): Boolean = underlyingNormalizable.isMatch
463
463
464
- def underlyingNormalizable (using Context ): Type = stripped.stripLazyRef match
465
- case tp : MatchType => tp
466
- case tp : AppliedType => tp.underlyingNormalizable
467
- case _ => NoType
468
-
469
464
/** Is this a higher-kinded type lambda with given parameter variances?
470
465
* These lambdas are used as the RHS of higher-kinded abstract types or
471
466
* type aliases. The variance info is strictly needed only for abstract types.
@@ -1480,22 +1475,25 @@ object Types extends TypeUtils {
1480
1475
}
1481
1476
deskolemizer(this )
1482
1477
1483
- /** The result of normalization using `tryNormalize`, or the type itself if
1484
- * tryNormlize yields NoType
1485
- */
1486
- final def normalized (using Context ): Type = {
1487
- val normed = tryNormalize
1488
- if (normed.exists) normed else this
1489
- }
1478
+ /** The result of normalization, or the type itself if none apply. */
1479
+ final def normalized (using Context ): Type = tryNormalize.orElse(this )
1490
1480
1491
1481
/** If this type has an underlying match type or applied compiletime.ops,
1492
1482
* then the result after applying all toplevel normalizations, otherwise NoType.
1493
1483
*/
1494
1484
def tryNormalize (using Context ): Type = underlyingNormalizable match
1495
- case mt : MatchType => mt.tryNormalize
1485
+ case mt : MatchType => mt.reduced.normalized
1496
1486
case tp : AppliedType => tp.tryCompiletimeConstantFold
1497
1487
case _ => NoType
1498
1488
1489
+ /** Perform successive strippings, and beta-reductions of applied types until
1490
+ * a match type or applied compiletime.ops is reached, if any, otherwise NoType.
1491
+ */
1492
+ def underlyingNormalizable (using Context ): Type = stripped.stripLazyRef match
1493
+ case tp : MatchType => tp
1494
+ case tp : AppliedType => tp.underlyingNormalizable
1495
+ case _ => NoType
1496
+
1499
1497
private def widenDealias1 (keep : AnnotatedType => Context ?=> Boolean )(using Context ): Type = {
1500
1498
val res = this .widen.dealias1(keep, keepOpaques = false )
1501
1499
if (res eq this ) res else res.widenDealias1(keep)
@@ -4517,9 +4515,10 @@ object Types extends TypeUtils {
4517
4515
case nil => x
4518
4516
foldArgs(op(x, tycon), args)
4519
4517
4520
- /** Exists if the tycon is a TypeRef of an alias with an underlying match type.
4521
- * Anything else should have already been reduced in `appliedTo` by the TypeAssigner.
4522
- * May reduce several HKTypeLambda applications before the underlying MatchType is reached.
4518
+ /** Exists if the tycon is a TypeRef of an alias with an underlying match type,
4519
+ * or a compiletime applied type. Anything else should have already been
4520
+ * reduced in `appliedTo` by the TypeAssigner. This may reduce several
4521
+ * HKTypeLambda applications before the underlying normalizable type is reached.
4523
4522
*/
4524
4523
override def underlyingNormalizable (using Context ): Type =
4525
4524
if ctx.period != validUnderlyingNormalizable then tycon match
@@ -4957,8 +4956,6 @@ object Types extends TypeUtils {
4957
4956
private var myReduced : Type | Null = null
4958
4957
private var reductionContext : util.MutableMap [Type , Type ] = _
4959
4958
4960
- override def tryNormalize (using Context ): Type =
4961
- reduced.normalized
4962
4959
4963
4960
def reduced (using Context ): Type = atPhaseNoLater(elimOpaquePhase) {
4964
4961
0 commit comments