Skip to content

Commit 4347c29

Browse files
committed
Make OrderingConstraint.order more accessible to readers
1 parent 4c122f4 commit 4347c29

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,10 +328,19 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
328328
else {
329329
assert(contains(param1))
330330
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.
331338
val newUpper = param2 :: exclusiveUpper(param2, param1)
339+
// Params param0 that *become* known-to-be-bigger than param2.
332340
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))
335344
current2
336345
}
337346

0 commit comments

Comments
 (0)