0

I've these two interfaces in my project:

sealed interface DataInput<T : DataModel<*>> { // <-- here's the deal (the "*")
    fun toModel(): T

    fun updateModel(model: T): T
}


sealed interface DataModel<T : DataInput<*>> { // <-- here's the deal (the "*")
    fun toInput(): T
}

I want to make it so that all classes that implement DataInput can create/modify T-type classes that implement DataModel and vice versa.
I wrote the above, but the IDE returns (rightly) this error: This type parameter violates the Finite Bound Restriction, but I don't know how to fix it.


EDIT: I've just found Creating circular generic references but it's about Java.
Is it simpler in Kotlin?

Giuseppe
  • 449
  • 1
  • 5
  • 14

0 Answers0