Reputation: 115
I have a class in java that accepts a generic type that extends another class How can I extend the first class in Kotlin?
I've already tried using out keyword but it's no good.
EntityFragment.java
public abstract class EntityFragment<T extends EntityModule> extends BaseFragment {
public EntityFragment(T module, boolean root) {
//some code
}
My kotlin class that I'm trying to write is as below:
open class WidthChangeNotifierFragment<out T : EntityStorage>(t: T, root: Boolean) : EntityFragment<T>(t, root) {
Upvotes: 4
Views: 5010
Reputation: 8422
You shouldn't use out
keyword in this case. You can just write
open class WidthChangeNotifierFragment<T : EntityModule>(t: T, root: Boolean) : EntityFragment<T>(t, root)
Upvotes: 2