@@ -328,10 +328,19 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
328
328
else {
329
329
assert(contains(param1))
330
330
assert(contains(param2))
331
+ // We add edge param1 <: param2 to the graph representing which params are known to be smaller
332
+ // than which other params, which is recorded in both lowerMap and upperMap.
333
+ // Since we store the *transitive closure* of the parameter subtyping relation, here
334
+ // we find all param0 <: param1, and param3 >: param2, and add all edges of form param0 <: param3,
335
+ // but without readding existing edges!
336
+
337
+ // Params param3 that *become* known-to-be-bigger than param1.
331
338
val newUpper = param2 :: exclusiveUpper(param2, param1)
339
+ // Params param0 that *become* known-to-be-bigger than param2.
332
340
val newLower = param1 :: exclusiveLower(param1, param2)
333
- val current1 = (current /: newLower)(upperLens.map(this , _, _, newUpper ::: _))
334
- val current2 = (current1 /: newUpper)(lowerLens.map(this , _, _, newLower ::: _))
341
+ // For each param0, prepend all param3 to the upper params.
342
+ val current1 = newLower.foldLeft(current)((curr, p) => upperLens.map(this , curr, p, upper => newUpper ::: upper))
343
+ val current2 = newUpper.foldLeft(current1)((curr, p) => lowerLens.map(this , curr, p, lower => newLower ::: lower))
335
344
current2
336
345
}
337
346
0 commit comments