Skip to content

Commit c9ef33f

Browse files
Regroup tryNormalize logic
Only AppliedType still overrides tryNormalize, but just for MatchTypeTrace purposes. Also drop `handleRecursive` from `tryNormalize`, it is already handled in `MatchType#reduced`.
1 parent bdda3e8 commit c9ef33f

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

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

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -468,11 +468,6 @@ object Types extends TypeUtils {
468468
/** Does this application expand to a match type? */
469469
def isMatchAlias(using Context): Boolean = underlyingMatchType.exists
470470

471-
def underlyingMatchType(using Context): Type = this.safeDealias.stripLazyRef match
472-
case tp: MatchType => tp
473-
case tp: AppliedType => tp.underlyingMatchType
474-
case _ => NoType
475-
476471
/** Is this a higher-kinded type lambda with given parameter variances?
477472
* These lambdas are used as the RHS of higher-kinded abstract types or
478473
* type aliases. The variance info is strictly needed only for abstract types.
@@ -1538,9 +1533,14 @@ object Types extends TypeUtils {
15381533
* of S[n] types, the result after applying all toplevel normalizations,
15391534
* otherwise NoType
15401535
*/
1541-
def tryNormalize(using Context): Type =
1542-
if isMatchAlias then underlyingMatchType.tryNormalize
1543-
else NoType
1536+
def tryNormalize(using Context): Type = underlyingMatchType match
1537+
case mt: MatchType => mt.reduced.normalized
1538+
case _ => NoType
1539+
1540+
def underlyingMatchType(using Context): Type = this.safeDealias.stripLazyRef match
1541+
case tp: MatchType => tp
1542+
case tp: AppliedType => tp.underlyingMatchType
1543+
case _ => NoType
15441544

15451545
private def widenDealias1(keep: AnnotatedType => Context ?=> Boolean)(using Context): Type = {
15461546
val res = this.widen.dealias1(keep, keepOpaques = false)
@@ -5085,13 +5085,6 @@ object Types extends TypeUtils {
50855085
private var myReduced: Type | Null = null
50865086
private var reductionContext: util.MutableMap[Type, Type] | Null = null
50875087

5088-
override def tryNormalize(using Context): Type =
5089-
try
5090-
reduced.normalized
5091-
catch
5092-
case ex: Throwable =>
5093-
handleRecursive("normalizing", s"${scrutinee.show} match ..." , ex)
5094-
50955088
private def thisMatchType = this
50965089

50975090
def reduced(using Context): Type = atPhaseNoLater(elimOpaquePhase) {

0 commit comments

Comments
 (0)