Resolve overriding conflicts on delegated classes

Hi guys! How can I achieve this?

fun main(args: Array<String>) {
    val obj = C()
    obj.a()
    obj.b()
    obj.foo()
}

interface A {
    fun a()
    fun foo()
}

interface B {
    fun b()
    fun foo()
}

class A1 : A {
    override fun foo() = Unit
    override fun a() = println("this is a!")
}

class B1 : B {
    override fun foo() = println("this is foo!")
    override fun b() = println("this is b!")
}

class C : A by A1(), B by B1() {
    override fun foo() {
        super<A>.foo()
    }
}

the line super<A>.foo() doesnt compile. “Abstract method cannot be accessed directly.”

You can do:

class C(private val a: A = A1()) : A by a, B by B1() {
  override fun foo() {
    a.foo()
  }
}
2 Likes

To my knowledge, they haven’t added the ability to use “super” to refer to delegates yet. I know it’s planned, but I don’t think they have it yet.