A generics question, if this is the right channel....
# announcements
d
A generics question, if this is the right channel. I think I have a legitimate use of an
out
parameter, but the compiler is complaining. Error: Type parameter T is declared as 'out' but occurs in 'in' position in type (T) -> C<T>
e
assuming
B : A
,
Copy code
val c = C<B>()
c.foo { value: A -> C<A>(value) }
should not be allowed, but would be if your function were accepted and
val c: C<A> = C<B>()
which is allowed by
<out T>
if you were to define it as a non-member function,
Copy code
fun <T> C<T>.foo(f: (T) -> C<T>): C<T>
it would be accepted, as you can't cause any issues with that
also
Copy code
class C<out T>(val member: T) {
    fun foo(f: (value: T) -> C<@UnsafeVariance T>): C<T>
}
is accepted, but as the annotation name indicates…