Probably a bit to early, but it would be great to see that the Kotlin-compiler chooses for the function with the most specific signature, even if generics are in play:
//from external sources
class MyData<T>(val param : T)
class SpecialValue<T>(val value: T)
//our extension-functions
@JvmName("specialFun1")
inline fun <reified T> fun1(data: MyData<SpecialValue<T>>, action: T.()->Unit = {}){
data.param.value.action()
}
inline fun <reified T> fun1(data: MyData<T>, action: T.()->Unit = {}){
data.param.action()
}
fun test(){
fun1(MyData(SpecialValue("hi"))){}
}
The real usecase in tornadoFX : Ambiguous "TableView.column()" extension signature · Issue #599 · edvin/tornadofx · GitHub