Skip to content

Commit 94a7765

Browse files
Use underlyingNormalizable in Type#tryNormalize
1 parent e47f635 commit 94a7765

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

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

+9-12
Original file line numberDiff line numberDiff line change
@@ -1532,11 +1532,13 @@ object Types extends TypeUtils {
15321532
if (normed.exists) normed else this
15331533
}
15341534

1535-
/** If this type can be normalized at the top-level by rewriting match types
1536-
* of S[n] types, the result after applying all toplevel normalizations,
1537-
* otherwise NoType
1535+
/** If this type has an underlying match type or applied compiletime.ops,
1536+
* then the result after applying all toplevel normalizations, otherwise NoType.
15381537
*/
1539-
def tryNormalize(using Context): Type = NoType
1538+
def tryNormalize(using Context): Type = underlyingNormalizable match
1539+
case mt: MatchType => mt.tryNormalize
1540+
case tp: AppliedType => tp.tryCompiletimeConstantFold
1541+
case _ => NoType
15401542

15411543
private def widenDealias1(keep: AnnotatedType => Context ?=> Boolean)(using Context): Type = {
15421544
val res = this.widen.dealias1(keep, keepOpaques = false)
@@ -4656,14 +4658,9 @@ object Types extends TypeUtils {
46564658
cachedUnderlyingNormalizable
46574659

46584660
override def tryNormalize(using Context): Type =
4659-
def tryMatchAlias =
4660-
if isMatchAlias then trace(i"normalize $this", typr, show = true):
4661-
if MatchTypeTrace.isRecording then
4662-
MatchTypeTrace.recurseWith(this)(superType.tryNormalize)
4663-
else
4664-
underlyingNormalizable.tryNormalize
4665-
else NoType
4666-
tryCompiletimeConstantFold.orElse(tryMatchAlias)
4661+
if isMatchAlias && MatchTypeTrace.isRecording then
4662+
MatchTypeTrace.recurseWith(this)(superType.tryNormalize)
4663+
else super.tryNormalize
46674664

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

0 commit comments

Comments
 (0)