@@ -591,37 +591,34 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
591
591
val replacement = tp.dealiasKeepAnnots.stripTypeVar
592
592
if param == replacement then this .checkWellFormed()
593
593
else
594
+ assert(replacement.isValueTypeOrLambda)
595
+
594
596
val droppedTypeVar = typeVarOfParam(param)
595
597
596
598
// println(i"replace $param, $droppedTypeVar with $replacement in $this")
597
599
val dropTypeVar = new TypeMap :
598
600
override def apply (t : Type ): Type =
599
601
if t.exists && (t eq droppedTypeVar) then param else mapOver(t)
600
602
601
- assert(replacement.isValueTypeOrLambda)
602
- var current =
603
- if isRemovable(param.binder) then remove(param.binder)
604
- else updateEntry(this , param, replacement)
603
+ var current = this
605
604
606
605
def removeParam (ps : List [TypeParamRef ]) = ps.filterConserve(param ne _)
607
-
608
- def replaceParam (entry : Type , atPoly : TypeLambda , atIdx : Int ): Type =
609
- val pref = atPoly.paramRefs(atIdx)
610
- val newEntry = current.ensureNonCyclic(pref, entry.substParam(param, replacement))
611
- adjustDeps(newEntry, entry, pref)
612
- newEntry
613
-
614
606
for lo <- lower(param) do
615
607
current = upperLens.map(this , current, lo, removeParam)
616
608
for hi <- upper(param) do
617
609
current = lowerLens.map(this , current, hi, removeParam)
618
610
619
611
current.foreachParam { (p, i) =>
620
612
val other = p.paramRefs(i)
621
- val oldEntry = current.entry(other)
622
- val newEntry = current.ensureNonCyclic(other, oldEntry.substParam(param, replacement))
623
- current = updateEntryNoOrdering(current, other, newEntry, dropTypeVar(oldEntry))
613
+ if other != param then
614
+ val oldEntry = current.entry(other)
615
+ val newEntry = current.ensureNonCyclic(other, oldEntry.substParam(param, replacement))
616
+ current = updateEntryNoOrdering(current, other, newEntry, dropTypeVar(oldEntry))
624
617
}
618
+
619
+ current =
620
+ if isRemovable(param.binder) then current.remove(param.binder)
621
+ else updateEntry(current, param, replacement)
625
622
current.dropDeps(param)
626
623
current.checkWellFormed()
627
624
end replace
0 commit comments