File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed
compiler/src/dotty/tools/dotc/core Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -79,9 +79,8 @@ trait ConstraintHandling {
79
79
def fullBounds (param : TypeParamRef )(using Context ): TypeBounds =
80
80
nonParamBounds(param).derivedTypeBounds(fullLowerBound(param), fullUpperBound(param))
81
81
82
- /** If true: eliminate wildcards in bounds by avoidance.
83
- * Otherwise replace them by fresh variables, except that
84
- * in mode TypeVarsMissContext, wildcards are always eliminated by approximation.
82
+ /** If true, eliminate wildcards in bounds by avoidance, otherwise replace
83
+ * them by fresh variables.
85
84
*/
86
85
protected def approximateWildcards : Boolean = true
87
86
@@ -96,7 +95,7 @@ trait ConstraintHandling {
96
95
if ! isUpper then variance = - 1
97
96
def apply (t : Type ): Type = t match
98
97
case t : WildcardType =>
99
- if approximateWildcards || ctx.mode.is( Mode . TypevarsMissContext ) then
98
+ if approximateWildcards then
100
99
val bounds = t.effectiveBounds
101
100
range(bounds.lo, bounds.hi)
102
101
else
Original file line number Diff line number Diff line change @@ -139,7 +139,14 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
139
139
try topLevelSubType(tp1, tp2)
140
140
finally useNecessaryEither = saved
141
141
142
- override protected def approximateWildcards : Boolean = useNecessaryEither
142
+ /** Use avoidance to get rid of wildcards in constraint bounds if
143
+ * we are doing a neccessary comparison, or the mode is TypeVarsMissContext.
144
+ * The idea is that under either of these conditions we are not interested
145
+ * in creating a fresh type variable to replace the wildcard. I verified
146
+ * that several tests break if one or the other part of the disjunction is dropped.
147
+ */
148
+ override protected def approximateWildcards : Boolean =
149
+ useNecessaryEither || ctx.mode.is(Mode .TypevarsMissContext )
143
150
144
151
def testSubType (tp1 : Type , tp2 : Type ): CompareResult =
145
152
GADTused = false
You can’t perform that action at this time.
0 commit comments