@@ -1181,7 +1181,7 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] w
1181
1181
* If the original left-hand type `leftRoot` is a path `p.type`,
1182
1182
* and the current widened left type is an application with wildcard arguments
1183
1183
* such as `C[_]`, where `X` is `C`'s type parameter corresponding to the `_` argument,
1184
- * compare with `C[p.X]` instead. Otherwise return `false` .
1184
+ * compare with `C[p.X]` instead. Otherwise approximate based on variance .
1185
1185
* Also do a capture conversion in either of the following cases:
1186
1186
*
1187
1187
* - If we are after typer. We generally relax soundness requirements then.
@@ -1203,10 +1203,18 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] w
1203
1203
* paths is less intrusive than skolemization.
1204
1204
*/
1205
1205
def compareCaptured (arg1 : TypeBounds , arg2 : Type ) = tparam match {
1206
- case tparam : Symbol
1207
- if leftRoot.isStable || (ctx.isAfterTyper || ctx.mode.is(Mode .TypevarsMissContext )) && leftRoot.member(tparam.name).exists =>
1208
- val captured = TypeRef (leftRoot, tparam)
1209
- isSubArg(captured, arg2)
1206
+ case tparam : Symbol =>
1207
+ if (leftRoot.isStable || (ctx.isAfterTyper || ctx.mode.is(Mode .TypevarsMissContext ))
1208
+ && leftRoot.member(tparam.name).exists) {
1209
+ val captured = TypeRef (leftRoot, tparam)
1210
+ isSubArg(captured, arg2)
1211
+ }
1212
+ else if (v > 0 )
1213
+ isSubType(paramBounds(tparam).hi, arg2)
1214
+ else if (v < 0 )
1215
+ isSubType(arg2, paramBounds(tparam).lo)
1216
+ else
1217
+ false
1210
1218
case _ =>
1211
1219
false
1212
1220
}
0 commit comments