Skip to content

Commit 06f4cff

Browse files
committed
Refine dependency tracking for bounds in replace
1 parent 96fc58c commit 06f4cff

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

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

Lines changed: 7 additions & 7 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}
@@ -411,7 +412,6 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
411412
tvars.copyToArray(entries1, nparams)
412413
newConstraint(boundsMap = this.boundsMap.updated(poly, entries1))
413414
.init(poly)
414-
.adjustDeps(poly, entries1, add = true)
415415
}
416416

417417
/** Split dependent parameters off the bounds for parameters in `poly`.
@@ -433,7 +433,8 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
433433
todos.dropInPlace(1)
434434
i += 1
435435
}
436-
current.checkWellFormed()
436+
current.adjustDeps(poly, current.boundsMap(poly).nn, add = true)
437+
.checkWellFormed()
437438
}
438439

439440
// ---------- Updates ------------------------------------------------------------
@@ -609,11 +610,10 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
609610
current = lowerLens.map(this, current, hi, removeParam)
610611

611612
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)
613+
val other = p.paramRefs(i)
614+
val oldEntry = current.entry(other)
615+
val newEntry = current.ensureNonCyclic(other, oldEntry.substParam(param, replacement))
616+
current = updateEntryNoOrdering(current, other, newEntry, oldEntry)
617617
}
618618
current.dropDeps(param)
619619
current.checkWellFormed()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ object Substituters:
193193
def apply(tp: Type): Type = substRecThis(tp, from, to, this)(using mapCtx)
194194
}
195195

196-
final class SubstParamMap(from: ParamRef, to: Type)(using Context) extends DeepTypeMap, IdempotentCaptRefMap {
196+
class SubstParamMap(from: ParamRef, to: Type)(using Context) extends DeepTypeMap, IdempotentCaptRefMap {
197197
def apply(tp: Type): Type = substParam(tp, from, to, this)(using mapCtx)
198198
}
199199

0 commit comments

Comments
 (0)