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