I have the following base class and interface
open class Base {
open fun foo() { println("Base.foo") }
}
fun interface Delegate {
fun foo(): Unit
}
Now I want to override the foo method of a subclass Composed of Base using delegation, like this:
class Composed(delegate: Delegate) : Base(), Delegate by delegate
This works as I intend. Instances of Composed use the foo method of delegate, instead of the one from Base. But, I get a warning from IntelliJ:
Delegated member 'fun foo(): Unit' hides supertype override: public open fun foo(): Unit defined in Base. Please specify proper override explicitly.
Why do I get this error? What is "bad" about implicitly overriding the foo method? Are there any drawbacks I don't see? Specifying the override explicitly seems like a lot of unnecessary code, especially if I do this for multiple methods and multiple subclasses.