Hi. Does anyone know why delegation for `fun` inte...
# announcements
i
Hi. Does anyone know why delegation for
fun
interface with lambdas (
class D
) doesn't work? I'd really want to use delegation that way, not like
class C
Copy code
fun interface A {
    fun f()
}

fun interface B {
    fun f()
}

class C(b: B) : A by A(b::f) //works

class D(b: B) : A by { b.f() } //doesn't work
v
Copy code
class D(b: B) : A by { b.f() } as A
e
Copy code
class D(b: B) : A by (A { b.f() })
i
@Vampire thats even worse, in your example if I remove
fun
for
interface A
it still compiles which is not a good option I think
😞 1
@ephemient this options is just another way to do like in
class C
. I can also use
by A({ b.f() })
but my question is why
{ b.f() }
doesn't work? I mean, it's intentional behavior or it's just compiler not as smart as I want? 🙂
e
type inference isn't smart enough, it seems. I think it's still better than C, as you can put arbitrary code in there beyond just a function reference