File tree Expand file tree Collapse file tree 2 files changed +25
-2
lines changed
compiler/src/dotty/tools/dotc/core Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -45,10 +45,16 @@ abstract class Constraint extends Showable {
45
45
/** The parameters that are known to be greater wrt <: than `param` */
46
46
def upper (param : TypeParamRef ): List [TypeParamRef ]
47
47
48
- /** `lower`, except that `minLower.forall(tpr => !minLower.exists(_ <:< tpr))` */
48
+ /** The lower dominator set.
49
+ *
50
+ * This is like `lower`, except that each parameter returned is no smaller than every other returned parameter.
51
+ */
49
52
def minLower (param : TypeParamRef ): List [TypeParamRef ]
50
53
51
- /** `upper`, except that `minUpper.forall(tpr => !minUpper.exists(tpr <:< _))` */
54
+ /** The upper dominator set.
55
+ *
56
+ * This is like `upper`, except that each parameter returned is no greater than every other returned parameter.
57
+ */
52
58
def minUpper (param : TypeParamRef ): List [TypeParamRef ]
53
59
54
60
/** lower(param) \ lower(butNot) */
Original file line number Diff line number Diff line change @@ -30,6 +30,23 @@ trait ConstraintHandling[AbstractContext] {
30
30
31
31
protected def isSubType (tp1 : Type , tp2 : Type )(implicit actx : AbstractContext ): Boolean
32
32
protected def isSameType (tp1 : Type , tp2 : Type )(implicit actx : AbstractContext ): Boolean
33
+
34
+ /** LUB of `tp1`, `tp2`.
35
+ *
36
+ * This should always be used instead of `tp1 | tp2`- it allows subclasses to change how
37
+ * type lubs are approximated.
38
+ *
39
+ * Normally when we take a LUB of two types (as in [[TypeComparer.lub ]]), we may approximate it -
40
+ * for instance, we can approximate `String("a") | String("b")` as `String`. The way we can do that in
41
+ * ConstraintHandling depends on how we can approximate the constraint itself - it's not always sound to,
42
+ * for instance, simplify `a >: String("a") | String("b")` to `a >: String`.
43
+ *
44
+ * For type inference (the Constraint in TyperState), we can approximate a constraint C by a constraint C'
45
+ * only if all solutions to C' are also solutions to C (solving C' must be _sufficient_ for solving C).
46
+ *
47
+ * For GADT constraint inference, we can only do that if all solutions to C are also solutions to C'
48
+ * (solving C' is _necessary_ for solving C).
49
+ */
33
50
protected def typeLub (tp1 : Type , tp2 : Type )(implicit actx : AbstractContext ): Type
34
51
35
52
protected def constraint : Constraint
You can’t perform that action at this time.
0 commit comments