Reified generics and extension-functions


#1

I want to add an extension-function to a class, that makes use of a reified parameter (see main)
When calling the function, we need to respecify the redundant generic.
This limits the amount of extension-functions we can at inside a dsl a lot.

class Eater<T>(init: Eater<T>.() = null)
fun <S, T: Any> Eater<S>.exec(clazz: KClass<T>){
    //using S and T here
}

inline fun <reified T: Any, S> Eater<S>.exec() = exec(T::class)

fun main(args: Array<String>) {
    Eater<String>().exec<Int>()         // I want this
   Eater<String>().exec<Int, String>() //at this moment we need to pass a redundant generic

    Eater<String>{
        exec<Int>()          // I want this
        exec<String, Int>() // at this moment we need to pass a redundant generic
     }
}