I'm wondering if there is a way to delegate an int...
# announcements
a
I'm wondering if there is a way to delegate an interface using
by
keyword and make all the delegated methods
final
. My use case is as follows:
Copy code
interface MyInterface {
    fun doSomething()
}

internal class MyInterfaceImpl : MyInterface {
    override fun doSomething() {
        // Do something here
    }
}

abstract class MyClass : MyInterface by MyInterfaceImpl() {
    abstract fun doSomethingElse()
}

class MyClassImpl : MyClass() {
    override fun doSomethingElse() {
        // Do something here
    }

    override fun doSomething() {
        // This override should be forbidden
        super.doSomething()
    }
}
d
I'm guessing making
MyInterfaceImpl.doSomething
final won't cut it?
a
Nope