Skip to content

Commit 8621dc4

Browse files
EugeneFlesselleprolativ
authored andcommitted
Use underlyingNormalizable in Type#tryNormalize
[Cherry-picked a6cadec]
1 parent cda1d40 commit 8621dc4

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,11 +1488,13 @@ object Types extends TypeUtils {
14881488
if (normed.exists) normed else this
14891489
}
14901490

1491-
/** If this type can be normalized at the top-level by rewriting match types
1492-
* of S[n] types, the result after applying all toplevel normalizations,
1493-
* otherwise NoType
1491+
/** If this type has an underlying match type or applied compiletime.ops,
1492+
* then the result after applying all toplevel normalizations, otherwise NoType.
14941493
*/
1495-
def tryNormalize(using Context): Type = NoType
1494+
def tryNormalize(using Context): Type = underlyingNormalizable match
1495+
case mt: MatchType => mt.tryNormalize
1496+
case tp: AppliedType => tp.tryCompiletimeConstantFold
1497+
case _ => NoType
14961498

14971499
private def widenDealias1(keep: AnnotatedType => Context ?=> Boolean)(using Context): Type = {
14981500
val res = this.widen.dealias1(keep, keepOpaques = false)
@@ -4532,14 +4534,9 @@ object Types extends TypeUtils {
45324534
cachedUnderlyingNormalizable
45334535

45344536
override def tryNormalize(using Context): Type =
4535-
def tryMatchAlias =
4536-
if isMatchAlias then trace(i"normalize $this", typr, show = true):
4537-
if MatchTypeTrace.isRecording then
4538-
MatchTypeTrace.recurseWith(this)(superType.tryNormalize)
4539-
else
4540-
underlyingNormalizable.tryNormalize
4541-
else NoType
4542-
tryCompiletimeConstantFold.orElse(tryMatchAlias)
4537+
if isMatchAlias && MatchTypeTrace.isRecording then
4538+
MatchTypeTrace.recurseWith(this)(superType.tryNormalize)
4539+
else super.tryNormalize
45434540

45444541
/** Is this an unreducible application to wildcard arguments?
45454542
* This is the case if tycon is higher-kinded. This means

0 commit comments

Comments
 (0)