@@ -19,15 +19,18 @@ sealed abstract class GadtConstraint extends Showable {
1919
2020 /** Full bounds of `sym`, including TypeRefs to other lower/upper symbols.
2121 *
22- * Note that underlying operations perform subtype checks - for this reason, recursing on `fullBounds`
23- * of some symbol when comparing types might lead to infinite recursion. Consider `bounds` instead.
22+ * @note this performs subtype checks between ordered symbols.
23+ * Using this in isSubType can lead to infinite recursion. Consider `bounds` instead.
2424 */
2525 def fullBounds (sym : Symbol )(implicit ctx : Context ): TypeBounds
2626
2727 /** Is `sym1` ordered to be less than `sym2`? */
2828 def isLess (sym1 : Symbol , sym2 : Symbol )(implicit ctx : Context ): Boolean
2929
30- /** Add symbols to constraint, preserving the underlying bounds and handling inter-dependencies. */
30+ /** Add symbols to constraint, correctly handling inter-dependencies.
31+ *
32+ * @see [[ConstraintHandling.addToConstraint ]]
33+ */
3134 def addToConstraint (syms : List [Symbol ])(implicit ctx : Context ): Boolean
3235 def addToConstraint (sym : Symbol )(implicit ctx : Context ): Boolean = addToConstraint(sym :: Nil )
3336
@@ -36,8 +39,7 @@ sealed abstract class GadtConstraint extends Showable {
3639
3740 /** Is the symbol registered in the constraint?
3841 *
39- * Note that this is returns `true` even if `sym` is already instantiated to some type,
40- * unlike [[Constraint.contains ]].
42+ * @note this is true even if the symbol is constrained to be equal to another type, unlike [[Constraint.contains ]].
4143 */
4244 def contains (sym : Symbol )(implicit ctx : Context ): Boolean
4345
@@ -81,8 +83,9 @@ final class ProperGadtConstraint private(
8183
8284 val poly1 = PolyType (params.map { sym => DepParamName .fresh(sym.name.toTypeName) })(
8385 pt => params.map { param =>
84- // replace the symbols in bound type `tp` which are in dependent positions
85- // with their internal TypeParamRefs
86+ // In bound type `tp`, replace the symbols in dependent positions with their internal TypeParamRefs.
87+ // The replaced symbols will be later picked up in `ConstraintHandling#addToConstraint`
88+ // and used as orderings.
8689 def substDependentSyms (tp : Type , isUpper : Boolean )(implicit ctx : Context ): Type = {
8790 def loop (tp : Type ) = substDependentSyms(tp, isUpper)
8891 tp match {
@@ -119,7 +122,7 @@ final class ProperGadtConstraint private(
119122 tv
120123 }
121124
122- // the replaced symbols will be stripped off the bounds by `addToConstraint` and used as orderings
125+ // The replaced symbols are picked up here.
123126 addToConstraint(poly1, tvars).reporting({ _ =>
124127 i " added to constraint: $params%, % \n $debugBoundsDescription"
125128 }, gadts)
0 commit comments