Skip to content

Commit 614c5b9

Browse files
committed
In replace, update param after updating dependent params
1 parent eed5803 commit 614c5b9

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,8 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
594594
val replacement = tp.dealiasKeepAnnots.stripTypeVar
595595
if param == replacement then this.checkWellFormed()
596596
else
597+
assert(replacement.isValueTypeOrLambda)
598+
597599
val droppedTypeVar = typeVarOfParam(param)
598600
//println(i"replace $param, $droppedTypeVar with $replacement in $this")
599601
val substParamAndDropTypeVar = new SubstParamMap(param, replacement):
@@ -603,13 +605,9 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
603605
replacement
604606
else super.apply(t)
605607

606-
assert(replacement.isValueTypeOrLambda)
607-
var current =
608-
if isRemovable(param.binder) then remove(param.binder)
609-
else updateEntry(this, param, replacement)
608+
var current = this
610609

611610
def removeParam(ps: List[TypeParamRef]) = ps.filterConserve(param ne _)
612-
613611
for lo <- lower(param) do
614612
current = upperLens.map(this, current, lo, removeParam)
615613
for hi <- upper(param) do
@@ -621,6 +619,10 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
621619
val newEntry = current.ensureNonCyclic(other, substParamAndDropTypeVar(oldEntry))
622620
current = updateEntryNoOrdering(current, other, newEntry, oldEntry)
623621
}
622+
623+
current =
624+
if isRemovable(param.binder) then current.remove(param.binder)
625+
else updateEntry(current, param, replacement)
624626
current.dropDeps(param)
625627
current.checkWellFormed()
626628
end replace

0 commit comments

Comments
 (0)