Andy Victors
11/08/2021, 8:13 PMclass Player : Listener<State> by ListenerBase<State>, Listener<Source> by ListenerBase<Source>
But why? Specified generic is a separate type to me. Why cannot I reuse one class for aggregation?Casey Brooks
11/08/2021, 8:44 PM@JvmName()
annotation on one of those functions to disambiguate the two functions in bytecode.
Implementing the same interfaces with different type parameters is less clear than extension functions on how it should work, though. While they are constrainted by JVM bytecode, I'd also argue that it is a good restriction in kotlin even without that; it would be clearer to have those callbacks be separate properties/functions within the class instead of being implemented by the class itselfAndy Victors
11/08/2021, 9:01 PMephemient
11/08/2021, 9:08 PMephemient
11/08/2021, 9:09 PMAndy Victors
11/08/2021, 9:57 PMinterface Listener<T> {
fun listen(value: T)
}
I expect it rolls out into separate methods:
...
fun listen(value: State)
fun listen(value: Source)
ephemient
11/08/2021, 10:04 PMAndy Victors
11/08/2021, 10:09 PMephemient
11/08/2021, 10:10 PMListener<in T>
➡️ Listener<State> & Listener<Source>
= fun listen(value: State | Source)
Supplier<out T>
➡️ Supplier<State> & Supplier<Source>
= fun get(): State & Source
but that's a way off tooephemient
11/08/2021, 10:12 PMfun get(): State
and fun get(): Source
definitely can't be allowed without more invasive language changesCasey Brooks
11/08/2021, 10:17 PMEither
monad, which gives you the same result but doesn't require any fundamental language changes, and makes it much more explicit in code the paths used for each of the two types in the unionephemient
11/08/2021, 10:36 PMelizarov
12/03/2021, 12:43 PM