https://kotlinlang.org logo
d

damian

08/17/2018, 9:13 PM
What am I missing with the variance here? I am getting
Type parameter T is declared as 'in' but occurs in 'out' position on type A<T>
on
B.bar
, which doesn't seem to make sense...
T
has
in
variance on
A<T>
. It works if make
T
invariant on
B<T>
(or use
@UnsafeVariance
) but I would like to have
in
on
T
for both
A
and
B
🤔
Copy code
interface A<in T : Any> {
    fun foo(value: T)
}
interface B<in T : Any> {
    fun bar(t: T, a: A<T>) // <- here
}
Played around with some sample situations/hierarchies and it's led me to believe the error is wrong, but...