Basically I have a generic class `A<X, Y>` w...
# kodein
s
Basically I have a generic class
A<X, Y>
which requires a
B<X, Y>
which requires a
C<X, Y>
. I want to bind many different types of
A
without duplicating much code. So, I tried creating a
fun <reified X, reified Y> bindIt(c: C<X, Y>)
that binds singletons
C<X, Y>
,
B<X, Y>
, and
A<X, Y>
and I call it with
bindIt<Foo, Bar>(C<Foo, Bar>())
. I expect this function to bind the singletons
C<Foo, Bar>
,
B<Foo, Bar>
,
A<Foo, Bar>
but it binds them all as
<X, Y>
instead of
<Foo, Bar>
. So, when I try to inject something of type
C<Foo, Bar>
, Kodein can't find any binding to use since it was bound to the generic type. Currently my workaround is to create a function that builds a concrete
C
, but that has the problem of not binding the intermediate products
A
,
B
but only the final product
C
.