@@ -331,39 +331,40 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
331
331
* and/or prefix of `bound`, just add the new parts of `bound`.
332
332
* @param isLower `bound` and `prevBound` are lower bounds
333
333
*/
334
- def adjustDelta (bound : Type , prevBound : Type , isLower : Boolean ): Boolean =
335
- if bound eq prevBound then true
334
+ def adjustDelta (bound : Type , prevBound : Type , isLower : Boolean , baseCase : => Boolean ): Boolean =
335
+ if bound eq prevBound then
336
+ baseCase
336
337
else bound match
337
338
case bound : AndOrType =>
338
- adjustDelta(bound.tp1, prevBound, isLower) && {
339
+ adjustDelta(bound.tp1, prevBound, isLower, baseCase ) && {
339
340
adjustReferenced(bound.tp2, isLower, add = true )
340
341
true
341
342
}
342
343
case _ => false
343
344
344
- /** Adjust dependencies to account for the delta of previous bound `prevBound `
345
- * and new bound `bound `.
346
- * @param isLower `bound` and `prevBound` are lower bounds
345
+ /** Adjust dependencies to account for the delta of previous bounds `prevBounds `
346
+ * and new bounds `bounds `.
347
+ * @param add true if the bounds are added, false if they are removed
347
348
*/
348
- def adjustBounds (bound : Type , prevBound : Type , isLower : Boolean ) =
349
- if ! adjustDelta(bound, prevBound, isLower) then
350
- adjustReferenced(prevBound, isLower, add = false )
351
- adjustReferenced(bound, isLower, add = true )
349
+ def adjustBounds (bounds : TypeBounds , add : Boolean ) =
350
+ adjustReferenced(bounds.lo, isLower = true , add)
351
+ adjustReferenced(bounds.hi, isLower = false , add)
352
352
353
353
entry match
354
- case TypeBounds (lo, hi) =>
354
+ case entry @ TypeBounds (lo, hi) =>
355
355
prevEntry match
356
- case TypeBounds (plo, phi) =>
357
- adjustBounds(lo, plo, isLower = true )
358
- adjustBounds(hi, phi, isLower = false )
356
+ case prevEntry @ TypeBounds (plo, phi) =>
357
+ if ! adjustDelta(lo, plo, isLower = true ,
358
+ adjustDelta(hi, phi, isLower = false , true ))
359
+ then
360
+ adjustBounds(prevEntry, add = false )
361
+ adjustBounds(entry, add = true )
359
362
case _ =>
360
- adjustReferenced(lo, isLower = true , add = true )
361
- adjustReferenced(hi, isLower = false , add = true )
363
+ adjustBounds(entry, add = true )
362
364
case _ =>
363
365
prevEntry match
364
- case TypeBounds (plo, phi) =>
365
- adjustReferenced(plo, isLower = true , add = false )
366
- adjustReferenced(phi, isLower = false , add = false )
366
+ case prevEntry : TypeBounds =>
367
+ adjustBounds(prevEntry, add = false )
367
368
case _ =>
368
369
dropDeps(srcParam)
369
370
this
@@ -608,7 +609,7 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
608
609
boundsLens.update(this , current, param, newEntry).adjustDeps(newEntry, oldEntry, param)
609
610
610
611
private def updateEntry (current : This , param : TypeParamRef , newEntry : Type )(using Context ): This = {
611
- // println(i"update $param to $tp in $current")
612
+ // println(i"update $param to $newEntry in $current")
612
613
if Config .checkNoWildcardsInConstraint then assert(! newEntry.containsWildcardTypes)
613
614
var current1 = updateEntryNoOrdering(current, param, newEntry, current.entry(param))
614
615
newEntry match {
0 commit comments