How to create a generic interface with a nested data class that uses this generic type in Kotlin?
Something like this:
interface Exemplary<T> {
data class Result(val value: T)
...
}
There's no e.g. Exemplary<Int>.Result but just Exemplary.Result; there's no T to be found without making Result generic as in Lukas' answer.
But there is an alternative: inner classes. If you want T to be fixed by the interface instance, e.g.
val x: Exemplary<Int> = ...
val y = new x.Result(3)
you need to make the class inner, but then it can't be data and you'll need to implement the methods yourself.