Skip to content

Commit 3d35817

Browse files
Pass current OrderingConstraint to stripParams
1 parent 191885c commit 3d35817

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

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

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -489,29 +489,27 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
489489
* @param isUpper If true, `bound` is an upper bound, else a lower bound.
490490
*/
491491
private def stripParams(
492+
current: OrderingConstraint,
492493
tp: Type,
493494
todos: mutable.ListBuffer[(OrderingConstraint, TypeParamRef) => OrderingConstraint],
494495
isUpper: Boolean)(using Context): Type = tp match {
495-
case param: TypeParamRef if contains(param) =>
496+
case param: TypeParamRef if current.contains(param) =>
496497
todos += (if isUpper then order(_, _, param) else order(_, param, _))
497498
NoType
498-
case tp: TypeBounds if tp.lo ne tp.hi =>
499-
// IMPROVE
500-
// - pass current ? or
501-
// - do opt in add too
502-
val lo1 = stripParams(tp.lo, todos, !isUpper).orElse(defn.NothingType)
503-
val hi1 = stripParams(tp.hi, todos, isUpper).orElse(tp.topType)
499+
case tp: TypeBounds =>
500+
val lo1 = stripParams(current, tp.lo, todos, !isUpper).orElse(defn.NothingType)
501+
val hi1 = stripParams(current, tp.hi, todos, isUpper).orElse(tp.topType)
504502
tp.derivedTypeBounds(lo1, hi1)
505503
case tp: AndType if isUpper =>
506-
val tp1 = stripParams(tp.tp1, todos, isUpper)
507-
val tp2 = stripParams(tp.tp2, todos, isUpper)
504+
val tp1 = stripParams(current, tp.tp1, todos, isUpper)
505+
val tp2 = stripParams(current, tp.tp2, todos, isUpper)
508506
if (tp1.exists)
509507
if (tp2.exists) tp.derivedAndType(tp1, tp2)
510508
else tp1
511509
else tp2
512510
case tp: OrType if !isUpper =>
513-
val tp1 = stripParams(tp.tp1, todos, isUpper)
514-
val tp2 = stripParams(tp.tp2, todos, isUpper)
511+
val tp1 = stripParams(current, tp.tp1, todos, isUpper)
512+
val tp2 = stripParams(current, tp.tp2, todos, isUpper)
515513
if (tp1.exists)
516514
if (tp2.exists) tp.derivedOrType(tp1, tp2)
517515
else tp1
@@ -542,7 +540,7 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
542540
while (i < poly.paramNames.length) {
543541
val param = poly.paramRefs(i)
544542
val bounds = dropWildcards(nonParamBounds(param))
545-
val stripped = stripParams(bounds, todos, isUpper = true)
543+
val stripped = stripParams(current, bounds, todos, isUpper = true)
546544
current = boundsLens.update(this, current, param, stripped)
547545
while todos.nonEmpty do
548546
current = todos.head(current, param)

0 commit comments

Comments
 (0)