jeggy
08/02/2021, 9:12 PMinterface A { val field: Int }
data class B(override val field: Int): A
fun <T: A> myFunction(property: KProperty1<T, Int>? = null) {
val kProperty = (property ?: A::field) as KProperty1<Any, Int>
/* Something */
}
fun main() {
myFunction(B::field)
}
Solved it with a small hack 👌ephemient
08/02/2021, 10:54 PMfun myFunction(property: KProperty1<out A, Int>)
?jeggy
08/03/2021, 8:32 AM<out T, Int>
. But that breaks the usage of kProperty.get
as now it requires a Nothing
object instead of T
or A
.