Hello guys
I’m trying to do it where I have an interface, say Base. I expect the implementors to override a function and return the list of their own member properties.
Let’s say the base interface is
interface Base {
fun getMemberProperties(): Collection<KProperty1<Base, *>>
}
Let’s say there’s a class Implementor that implements this Base interface.
data class Implementor: Base {
override fun getMemberProperties(): Collection<KProperty1<Implementor, *>>
}
The problem is the return type of the implementing class is Collection<KProperty1<Implementor, *>> as compared to Collection<KProperty1<Base, *>> and it doesn’t compile.
So how can I get the function signature in the interface to say any class of the Base type and not exactly Base type.
So this is similar to Java’s ? extends Base and I’ve read up on Kotlin’s covariance but it’s not helped me.
Help appreciated. Currently I’m getting away by returning Collection<KProperty1<,>>
Help appreciated.