@@ -11,6 +11,7 @@ import config.Config
11
11
import config .Printers .constr
12
12
import reflect .ClassTag
13
13
import Constraint .ReverseDeps
14
+ import Substituters .SubstParamMap
14
15
import annotation .tailrec
15
16
import annotation .internal .sharable
16
17
import cc .{CapturingType , derivedCapturingType }
@@ -590,6 +591,15 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
590
591
val replacement = tp.dealiasKeepAnnots.stripTypeVar
591
592
if param == replacement then this .checkWellFormed()
592
593
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
+
593
603
assert(replacement.isValueTypeOrLambda)
594
604
var current =
595
605
if isRemovable(param.binder) then remove(param.binder)
@@ -609,11 +619,10 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
609
619
current = lowerLens.map(this , current, hi, removeParam)
610
620
611
621
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)
617
626
}
618
627
current.dropDeps(param)
619
628
current.checkWellFormed()
0 commit comments