Have a generics puzzler, I want to define a functi...
# announcements
i
Have a generics puzzler, I want to define a function as follows:
inline fun <reified T : Any, E : Element> ElementCreator<E>.render(d : ElementCreator<E>.(T) -> Unit) {
When I call it I need to supply both type parameters, ie:
Copy code
render<Entity.List, BodyElement> { it -> … }
Note that
this
will be an
ElementCreator<Something>
. My question is: why can’t the second type parameter
E
be inferred from the type of
this
, why do I need to supply it when I call
render
?