I have the following code:
public class AnotherClass<L> {
public fun doStuffTo(obj: L) {
...
}
}
public class MyClass<T:MyClass<T>> : Cloneable {
val anotherClass:AnotherClass<T>;
public fun doStuff() {
anotherClass.doStuffTo(this as T);
}
public fun clone(): T {
val result = super.clone() as T
…
return result;
}
}
I’d like to remove the requirement of having a recursive generic and casting this
to T, if possible. I’m adding it just to reference the current instance class, like in Java. But maybe there is a better way of doing this in Kotlin?