@@ -1181,7 +1181,7 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] w
11811181 * If the original left-hand type `leftRoot` is a path `p.type`,
11821182 * and the current widened left type is an application with wildcard arguments
11831183 * 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 .
11851185 * Also do a capture conversion in either of the following cases:
11861186 *
11871187 * - If we are after typer. We generally relax soundness requirements then.
@@ -1203,10 +1203,18 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] w
12031203 * paths is less intrusive than skolemization.
12041204 */
12051205 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
12101218 case _ =>
12111219 false
12121220 }
0 commit comments