@@ -355,13 +355,25 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
355
355
assert(contains(param2), i " $param2" )
356
356
// Is `order` called during parameter unification?
357
357
val unifying = isLess(param2, param1)
358
- val newUpper = param2 :: exclusiveUpper(param2, param1).filterNot(_ eq param1)
359
- val newLower =
358
+ val newUpper = {
359
+ val up = exclusiveUpper(param2, param1)
360
+ if unifying then
361
+ // Since param2 <:< param1 already holds now, filter out param1 to avoid adding
362
+ // duplicated orderings.
363
+ param2 :: up.filterNot(_ eq param1)
364
+ else
365
+ param2 :: up
366
+ }
367
+ val newLower = {
368
+ val lower = exclusiveLower(param1, param2)
360
369
if unifying then
361
370
// Do not add bounds for param1 since it will be unified to param2 soon.
362
- exclusiveLower(param1, param2).filterNot(_ eq param2)
371
+ // And, similarly filter out param2 from lowerly-ordered parameters
372
+ // to avoid duplicated orderings.
373
+ lower.filterNot(_ eq param2)
363
374
else
364
- param1 :: exclusiveLower(param1, param2).filterNot(_ eq param2)
375
+ param1 :: lower
376
+ }
365
377
val current1 = newLower.foldLeft(current)(upperLens.map(this , _, _, newUpper ::: _))
366
378
val current2 = newUpper.foldLeft(current1)(lowerLens.map(this , _, _, newLower ::: _))
367
379
current2
0 commit comments