dave08
07/07/2024, 12:35 PMby
delegation for an interface with two different type parameters? Is there some kind of workaround to this?
interface Foo<T> { ... }
class Bar(val foo1: Foo<Baz>, val Foo<Baz2>): Foo<Baz> by foo1, Foo<Baz2> by foo2
Gleb Minaev
07/07/2024, 1:27 PMinterface Foo<T>
interface Baz
interface Baz2
class Bar: Foo<Baz>, Foo<Baz2>
dave08
07/07/2024, 1:30 PMVampire
07/07/2024, 2:18 PMclass Bar: Foo<*>, Foo<*>
and where you used T
, Any
.Vampire
07/07/2024, 2:22 PMdave08
07/07/2024, 2:23 PMclass Foo1 : Foo<Baz> { override fun Baz.build(...): Baz ... }
class Foo2 : Foo<Baz2> { override fun Baz2.build(...): Baz2 ... }
dave08
07/07/2024, 2:24 PMin
or out
there?asdf asdf
07/07/2024, 10:04 PMclass Bar(val foo1: Foo1, val foo2: Foo2) : Foo<Baz1> by foo1, Foo<Baz2> by foo2
fun test(foo: Foo<*>) {
foo.baz()
}
val thing: Bar = createBar()
test(thing)
How would test
choose between calling baz
on foo1 or foo2?