Skip to content

Commit 7d2872f

Browse files
committed
Add doc comments
1 parent 43f70cf commit 7d2872f

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,16 +277,28 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
277277
case _ =>
278278
traverseChildren(t)
279279

280+
/** Adjust dependencies to account for the delta of previous entry `prevEntry`
281+
* and new bound `entry` for the type variable `tvar`.
282+
*/
280283
def adjustDeps(entry: Type | Null, prevEntry: Type | Null, tvar: Type | Null)(using Context): this.type =
281284
tvar match
282285
case tvar: TypeVar =>
283286
val adjuster = new Adjuster(tvar)
284287

288+
/** Adjust reverse depemdencies of all type variables referenced by `bound`
289+
* @param isLower `bound` is a lower bound
290+
* @param add if true, add referenced variables to dependencoes, otherwise drop them.
291+
*/
285292
def adjustReferenced(bound: Type, isLower: Boolean, add: Boolean) =
286293
adjuster.variance = if isLower then 1 else -1
287294
adjuster.add = add
288295
adjuster.traverse(bound)
289296

297+
/** Use an optimized strategy to adjust dependencies to account for the delta
298+
* of previous bound `prevBound` and new bound `bound`: If `prevBound` is some
299+
* and/or prefix of `bound`, just add the new parts of `bound`.
300+
* @param isLower `bound` and `prevBound` are lower bounds
301+
*/
290302
def adjustDelta(bound: Type, prevBound: Type, isLower: Boolean): Boolean =
291303
if bound eq prevBound then true
292304
else bound match
@@ -297,6 +309,10 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
297309
}
298310
case _ => false
299311

312+
/** Adjust dependencies to account for the delta of previous bound `prevBound`
313+
* and new bound `bound`.
314+
* @param isLower `bound` and `prevBound` are lower bounds
315+
*/
300316
def adjustBounds(bound: Type, prevBound: Type, isLower: Boolean) =
301317
if !adjustDelta(bound, prevBound, isLower) then
302318
adjustReferenced(prevBound, isLower, add = false)
@@ -322,19 +338,25 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
322338
this
323339
end adjustDeps
324340

341+
/** Adjust dependencies to account for adding or dropping `entries` to the
342+
* constraint.
343+
* @param add if true, entries is added, otherwise it is dropped
344+
*/
325345
def adjustDeps(entries: Array[Type], add: Boolean)(using Context): this.type =
326346
for n <- 0 until paramCount(entries) do
327347
if add
328348
then adjustDeps(entries(n), NoType, typeVar(entries, n))
329349
else adjustDeps(NoType, entries(n), typeVar(entries, n))
330350
this
331351

352+
/** If `tp` is a type variable, remove all its reverse dependencies */
332353
def dropDeps(tp: Type)(using Context): Unit = tp match
333354
case tv: TypeVar =>
334355
coDeps = coDeps.remove(tv)
335356
contraDeps = contraDeps.remove(tv)
336357
case _ =>
337358

359+
/** A string representing the two depenecy maps */
338360
def depsToString(using Context): String =
339361
def depsStr(deps: SimpleIdentityMap[TypeVar, TypeVars]): String =
340362
def depStr(tv: TypeVar) = i"$tv --> ${deps(tv).nn.toList}%, %"

0 commit comments

Comments
 (0)