@@ -19,15 +19,18 @@ sealed abstract class GadtConstraint extends Showable {
19
19
20
20
/** Full bounds of `sym`, including TypeRefs to other lower/upper symbols.
21
21
*
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.
24
24
*/
25
25
def fullBounds (sym : Symbol )(implicit ctx : Context ): TypeBounds
26
26
27
27
/** Is `sym1` ordered to be less than `sym2`? */
28
28
def isLess (sym1 : Symbol , sym2 : Symbol )(implicit ctx : Context ): Boolean
29
29
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
+ */
31
34
def addToConstraint (syms : List [Symbol ])(implicit ctx : Context ): Boolean
32
35
def addToConstraint (sym : Symbol )(implicit ctx : Context ): Boolean = addToConstraint(sym :: Nil )
33
36
@@ -36,8 +39,7 @@ sealed abstract class GadtConstraint extends Showable {
36
39
37
40
/** Is the symbol registered in the constraint?
38
41
*
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 ]].
41
43
*/
42
44
def contains (sym : Symbol )(implicit ctx : Context ): Boolean
43
45
@@ -81,8 +83,9 @@ final class ProperGadtConstraint private(
81
83
82
84
val poly1 = PolyType (params.map { sym => DepParamName .fresh(sym.name.toTypeName) })(
83
85
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.
86
89
def substDependentSyms (tp : Type , isUpper : Boolean )(implicit ctx : Context ): Type = {
87
90
def loop (tp : Type ) = substDependentSyms(tp, isUpper)
88
91
tp match {
@@ -119,7 +122,7 @@ final class ProperGadtConstraint private(
119
122
tv
120
123
}
121
124
122
- // the replaced symbols will be stripped off the bounds by `addToConstraint` and used as orderings
125
+ // The replaced symbols are picked up here.
123
126
addToConstraint(poly1, tvars).reporting({ _ =>
124
127
i " added to constraint: $params%, % \n $debugBoundsDescription"
125
128
}, gadts)
0 commit comments