Skip to content

Commit 74451b7

Browse files
EugeneFlesselleWojciechMazur
authored andcommitted
Use underlyingNormalizable in Type#tryNormalize
[Cherry-picked a6cadec]
1 parent 6964304 commit 74451b7

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
@@ -1556,11 +1556,13 @@ object Types extends TypeUtils {
15561556
if (normed.exists) normed else this
15571557
}
15581558

1559-
/** If this type can be normalized at the top-level by rewriting match types
1560-
* of S[n] types, the result after applying all toplevel normalizations,
1561-
* otherwise NoType
1559+
/** If this type has an underlying match type or applied compiletime.ops,
1560+
* then the result after applying all toplevel normalizations, otherwise NoType.
15621561
*/
1563-
def tryNormalize(using Context): Type = NoType
1562+
def tryNormalize(using Context): Type = underlyingNormalizable match
1563+
case mt: MatchType => mt.tryNormalize
1564+
case tp: AppliedType => tp.tryCompiletimeConstantFold
1565+
case _ => NoType
15641566

15651567
private def widenDealias1(keep: AnnotatedType => Context ?=> Boolean)(using Context): Type = {
15661568
val res = this.widen.dealias1(keep, keepOpaques = false)
@@ -4693,14 +4695,9 @@ object Types extends TypeUtils {
46934695
cachedUnderlyingNormalizable
46944696

46954697
override def tryNormalize(using Context): Type =
4696-
def tryMatchAlias =
4697-
if isMatchAlias then trace(i"normalize $this", typr, show = true):
4698-
if MatchTypeTrace.isRecording then
4699-
MatchTypeTrace.recurseWith(this)(superType.tryNormalize)
4700-
else
4701-
underlyingNormalizable.tryNormalize
4702-
else NoType
4703-
tryCompiletimeConstantFold.orElse(tryMatchAlias)
4698+
if isMatchAlias && MatchTypeTrace.isRecording then
4699+
MatchTypeTrace.recurseWith(this)(superType.tryNormalize)
4700+
else super.tryNormalize
47044701

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

0 commit comments

Comments
 (0)