@@ -90,39 +90,22 @@ trait ConstraintHandling[AbstractContext] {
90
90
91
91
/** Adjust the bound `tp` in the following ways:
92
92
*
93
- * 1. Any toplevel occurrences of the compared parameter `param` are
94
- * replaced by `Nothing` if bound is from below or `Any` otherwise.
95
- * 2. Toplevel occurrences of TypeVars over TypeRefs in the current
96
- * constraint are dereferenced.
97
- * 3. Toplevel occurrences of TypeRefs that are instantiated in the current
93
+ * 1. Toplevel occurrences of TypeRefs that are instantiated in the current
98
94
* constraint are also dereferenced.
99
- * 4 . Toplevel occurrences of ExprTypes lead to a `NoType` return, which
95
+ * 2 . Toplevel occurrences of ExprTypes lead to a `NoType` return, which
100
96
* causes the addOneBound operation to fail.
101
97
*
102
- * An occurrence is toplevel if it is the bound itself,
103
- * or the bound is a union or intersection, and the ocurrence is
104
- * toplevel in one of the operands of the `&` or `|`.
98
+ * An occurrence is toplevel if it is the bound itself, or a term in some
99
+ * combination of `&` or `|` types.
105
100
*/
106
101
def adjust (tp : Type ): Type = tp match
107
102
case tp : AndOrType =>
108
103
val p1 = adjust(tp.tp1)
109
104
val p2 = adjust(tp.tp2)
110
105
if p1.exists && p2.exists then tp.derivedAndOrType(p1, p2) else NoType
111
- case tp : TypeParamRef =>
112
- if constraint.contains(tp) then
113
- constr.println(i " ${if tp eq param then " stripping" else " keeping" } $tp from $rawBound, upper = $isUpper in $constraint" )
114
- if tp eq param then // (1)
115
- if isUpper then defn.AnyType else defn.NothingType
116
- else constraint.entry(tp) match // (3)
117
- case NoType => tp
118
- case TypeBounds (lo, hi) => if lo eq hi then adjust(lo) else tp
119
- case inst => adjust(inst)
120
- case tp : TypeVar => // (2)
121
- val underlying1 = adjust(tp.underlying)
122
- if (underlying1 ne tp.underlying) || constraint.contains(tp.origin)
123
- then underlying1
124
- else tp
125
- case tp : ExprType => // (4)
106
+ case tp : TypeVar if constraint.contains(tp.origin) =>
107
+ adjust(tp.underlying)
108
+ case tp : ExprType =>
126
109
// ExprTypes are not value types, so type parameters should not
127
110
// be instantiated to ExprTypes. A scenario where such an attempted
128
111
// instantiation can happen is if we unify (=> T) => () with A => ()
@@ -468,7 +451,7 @@ trait ConstraintHandling[AbstractContext] {
468
451
* missing.
469
452
*/
470
453
def avoidLambdaParams (tp : Type ) =
471
- if ( comparedTypeLambdas.nonEmpty) {
454
+ if comparedTypeLambdas.nonEmpty then
472
455
val approx = new ApproximatingTypeMap {
473
456
if (! fromBelow) variance = - 1
474
457
def apply (t : Type ): Type = t match {
@@ -480,7 +463,6 @@ trait ConstraintHandling[AbstractContext] {
480
463
}
481
464
}
482
465
approx(tp)
483
- }
484
466
else tp
485
467
486
468
def addParamBound (bound : TypeParamRef ) =
0 commit comments