@@ -11,7 +11,6 @@ import config.Config
11
11
import config .Printers .constr
12
12
import reflect .ClassTag
13
13
import Constraint .ReverseDeps
14
- import NameKinds .DepParamName
15
14
import annotation .tailrec
16
15
import annotation .internal .sharable
17
16
import cc .{CapturingType , derivedCapturingType }
@@ -223,7 +222,7 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
223
222
if tvar == null then NoType
224
223
else tvar
225
224
226
- // ------------- TypeVar dependencies -----------------------------------
225
+ // ------------- Type parameter dependencies ----- -----------------------------------
227
226
228
227
var coDeps, contraDeps : ReverseDeps = SimpleIdentityMap .empty
229
228
@@ -233,10 +232,11 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
233
232
tv.origin
234
233
val param = origin(tv)
235
234
val excluded = except.map(origin)
235
+ val qualifies : TypeParamRef => Boolean = ! excluded.contains(_)
236
236
def test (deps : ReverseDeps , lens : ConstraintLens [List [TypeParamRef ]]) =
237
237
val depending = deps(param)
238
- null != depending && depending.exists(! excluded.contains(_) )
239
- || lens(this , tv.origin.binder, tv.origin.paramNum).exists(! excluded.contains(_) )
238
+ null != depending && depending.exists(qualifies )
239
+ || lens(this , tv.origin.binder, tv.origin.paramNum).exists(qualifies )
240
240
// .showing(i"outer depends on $tv with ${tvdeps.toList}%, % = $result")
241
241
if co then test(coDeps, upperLens) else test(contraDeps, lowerLens)
242
242
@@ -259,12 +259,12 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
259
259
end Adjuster
260
260
261
261
/** Adjust dependencies to account for the delta of previous entry `prevEntry`
262
- * and new bound `entry` for the type variable `tvar `.
262
+ * and new bound `entry` for the type parameter `srcParam `.
263
263
*/
264
264
def adjustDeps (entry : Type | Null , prevEntry : Type | Null , srcParam : TypeParamRef )(using Context ): this .type =
265
265
val adjuster = new Adjuster (srcParam)
266
266
267
- /** Adjust reverse depemdencies of all type parameters referenced by `bound`
267
+ /** Adjust reverse dependencies of all type parameters referenced by `bound`
268
268
* @param isLower `bound` is a lower bound
269
269
* @param add if true, add referenced variables to dependencoes, otherwise drop them.
270
270
*/
@@ -316,8 +316,8 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
316
316
this
317
317
end adjustDeps
318
318
319
- /** Adjust dependencies to account for adding or dropping `entries` to the
320
- * constraint .
319
+ /** Adjust dependencies to account for adding or dropping all `entries` associated
320
+ * with `poly` .
321
321
* @param add if true, entries is added, otherwise it is dropped
322
322
*/
323
323
def adjustDeps (poly : TypeLambda , entries : Array [Type ], add : Boolean )(using Context ): this .type =
@@ -327,7 +327,7 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
327
327
else adjustDeps(NoType , entries(n), poly.paramRefs(n))
328
328
this
329
329
330
- /** If `tp` is a type variable, remove all its reverse dependencies */
330
+ /** Remove all reverse dependencies of `param` */
331
331
def dropDeps (param : TypeParamRef )(using Context ): Unit =
332
332
coDeps = coDeps.remove(param)
333
333
contraDeps = contraDeps.remove(param)
@@ -589,8 +589,11 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
589
589
590
590
def removeParam (ps : List [TypeParamRef ]) = ps.filterConserve(param ne _)
591
591
592
- def replaceParam (tp : Type , atPoly : TypeLambda , atIdx : Int ): Type =
593
- current.ensureNonCyclic(atPoly.paramRefs(atIdx), tp.substParam(param, replacement))
592
+ def replaceParam (entry : Type , atPoly : TypeLambda , atIdx : Int ): Type =
593
+ val pref = atPoly.paramRefs(atIdx)
594
+ val newEntry = current.ensureNonCyclic(pref, entry.substParam(param, replacement))
595
+ adjustDeps(newEntry, entry, pref)
596
+ newEntry
594
597
595
598
current.foreachParam { (p, i) =>
596
599
current = boundsLens.map(this , current, p, i,
0 commit comments