Skip to content

Commit 1e19250

Browse files
committed
Remove use of simplified in MT reduction
I gave match type's redux an extension to the normalize algorithm, in order to make the test suite pass, as well as add an extra recursion to the simplify algorithm. A few neg tests tweaked and some other code changes could be dropped.
1 parent 9726e1a commit 1e19250

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3136,15 +3136,15 @@ class TrackingTypeComparer(initctx: Context) extends TypeComparer(initctx) {
31363136
case param @ TypeParamRef(b, n) if b eq caseLambda =>
31373137
insts(n) =
31383138
if canApprox then
3139-
approximation(param, fromBelow = variance >= 0, Int.MaxValue).simplified
3139+
approximation(param, fromBelow = variance >= 0, Int.MaxValue).normalized
31403140
else constraint.entry(param) match
31413141
case entry: TypeBounds =>
31423142
val lo = fullLowerBound(param)
31433143
val hi = fullUpperBound(param)
3144-
if !poisoned(param) && isSubType(hi, lo) then lo.simplified else Range(lo, hi)
3144+
if !poisoned(param) && isSubType(hi, lo) then lo.normalized else Range(lo, hi)
31453145
case inst =>
31463146
assert(inst.exists, i"param = $param\nconstraint = $constraint")
3147-
if !poisoned(param) then inst.simplified else Range(inst, inst)
3147+
if !poisoned(param) then inst.normalized else Range(inst, inst)
31483148
insts
31493149
case _ =>
31503150
foldOver(insts, t)
@@ -3166,6 +3166,11 @@ class TrackingTypeComparer(initctx: Context) extends TypeComparer(initctx) {
31663166
}
31673167
}
31683168

3169+
def normalizeHard(tp: Type): Type = tp.tryNormalize.orElse(tp match {
3170+
case tp: AppliedType => tp.map(normalizeHard)
3171+
case _ => tp
3172+
})
3173+
31693174
/** Match a single case. */
31703175
def matchCase(cas: Type): MatchResult = trace(i"$scrut match ${MatchTypeTrace.caseText(cas)}", matchTypes, show = true) {
31713176
val cas1 = cas match {
@@ -3229,7 +3234,7 @@ class TrackingTypeComparer(initctx: Context) extends TypeComparer(initctx) {
32293234
MatchTypeTrace.noInstance(scrut, cas, fails)
32303235
NoType
32313236
case MatchResult.Reduced(tp) =>
3232-
tp.simplified
3237+
normalizeHard(tp)
32333238
case Nil =>
32343239
val casesText = MatchTypeTrace.noMatchesText(scrut, cases)
32353240
ErrorType(reporting.MatchTypeNoCases(casesText))

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ object TypeOps:
147147
isFullyDefined(tp, ForceDegree.all)
148148
case _ =>
149149
val normed = tp.tryNormalize
150-
if normed.exists then normed else tp.map(simplify(_, theMap))
150+
if normed.exists then simplify(normed, theMap) else tp.map(simplify(_, theMap))
151151
case tp: TypeParamRef =>
152152
val tvar = ctx.typerState.constraint.typeVarOfParam(tp)
153153
if tvar.exists then tvar else tp
@@ -184,7 +184,7 @@ object TypeOps:
184184
else tp.derivedAnnotatedType(parent1, annot)
185185
case _: MatchType =>
186186
val normed = tp.tryNormalize
187-
if (normed.exists) normed else mapOver
187+
if (normed.exists) simplify(normed, theMap) else mapOver
188188
case tp: MethodicType =>
189189
// See documentation of `Types#simplified`
190190
val addTypeVars = new TypeMap with IdempotentCaptRefMap:

compiler/test/dotc/pos-test-pickling.blacklist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ i15158.scala
5151
i15155.scala
5252
i15827.scala
5353
i17149.scala
54+
tuple-fold.scala
5455

5556
# Opaque type
5657
i5720.scala

0 commit comments

Comments
 (0)