-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathi16018e.scala
More file actions
32 lines (24 loc) · 1.26 KB
/
i16018e.scala
File metadata and controls
32 lines (24 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// HKT-nested negative coverage for `TypeComparer.compareCaptured` (#16018).
//
// The flat negative matrix in i16018c.scala pins the basic variance
// directions. These cases pin that the same per-position variance checks keep
// firing when the wildcard is nested under an outer covariant container.
object Test:
class Co[+T]
class Inv[T]
// ---- A. Function1: contravariant slot + upper-bounded wildcard ------
//
// Outer `Co` covariant descends to `Function1[? <: M, R] <: Function1[M, R]`.
// The T1 slot has v < 0, so contravariant + upper must not widen.
def fn_contra_upper_in_co[M, R](xs: Co[Function1[? <: M, R]])
: Co[Function1[M, R]] = xs // error
// ---- B. Function1: covariant slot + lower-bounded wildcard ----------
//
// Dual to (A). The R slot has v > 0, so covariant + lower must not widen.
def fn_co_lower_in_co[M, T1](xs: Co[Function1[T1, ? >: M]])
: Co[Function1[T1, M]] = xs // error
// ---- C. Invariant slot nested under covariant container -------------
//
// Nesting inside a covariant outer container must not smuggle widening
// past an invariant inner slot.
def inv_in_co[M](xs: Co[Inv[? <: M]]): Co[Inv[M]] = xs // error