Skip to content

Commit 4a01bbd

Browse files
committed
Drop references to replaced TypeVar in replace (2)
1 parent 31e07ef commit 4a01bbd

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import config.Config
1111
import config.Printers.constr
1212
import reflect.ClassTag
1313
import Constraint.ReverseDeps
14+
import Substituters.SubstParamMap
1415
import annotation.tailrec
1516
import annotation.internal.sharable
1617
import cc.{CapturingType, derivedCapturingType}
@@ -590,6 +591,15 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
590591
val replacement = tp.dealiasKeepAnnots.stripTypeVar
591592
if param == replacement then this.checkWellFormed()
592593
else
594+
val droppedTypeVar = typeVarOfParam(param)
595+
//println(i"replace $param, $droppedTypeVar with $replacement in $this")
596+
val substParamAndDropTypeVar = new SubstParamMap(param, replacement):
597+
override def apply(t: Type): Type =
598+
if t eq droppedTypeVar then
599+
//println(i"DROP $t")
600+
replacement
601+
else super.apply(t)
602+
593603
assert(replacement.isValueTypeOrLambda)
594604
var current =
595605
if isRemovable(param.binder) then remove(param.binder)
@@ -609,11 +619,10 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
609619
current = lowerLens.map(this, current, hi, removeParam)
610620

611621
current.foreachParam { (p, i) =>
612-
current = boundsLens.map(this, current, p, i,
613-
entry =>
614-
val newEntry = replaceParam(entry, p, i)
615-
adjustDeps(newEntry, entry, p.paramRefs(i))
616-
newEntry)
622+
val other = p.paramRefs(i)
623+
val oldEntry = current.entry(other)
624+
val newEntry = current.ensureNonCyclic(other, substParamAndDropTypeVar(oldEntry))
625+
current = updateEntryNoOrdering(current, other, newEntry, oldEntry)
617626
}
618627
current.dropDeps(param)
619628
current.checkWellFormed()

0 commit comments

Comments
 (0)