What’s wrong with that?
Actually that’s what I would like to have.
Inheritance and export
s are two completely different mechanisms (even the result looks similar on the surface). One is dynamic dispatch, the other is static dispatch. Those things aren’t freely interchangeable!
You need both, because depending on context one of the two ways to implement something may be infeasible.
But both ways should be similarly first-class features. (Actually, static dispatch, together with delegation, is for most use-cases the more favorable approach, whereas dynamic dispatch is only needed in some very special circumstances. Java “just” got the defaults wrong; as with almost all other defaults actually. Copying Java was a very bad idea. Rust shows how things should be regarding the defaults. That’s why Rust “is fast and efficient” by default.)
Scala could do a really great job here too, imho. Because we can make dynamic and static dispatch look almost the same. Just a little syntax twist in the declaration. That would be better than what Rust has, with their dyn trait
s “bolted on”.
But this means that static dispatch (together with powerful tools for delegation) needs to become a first-class citizen in Scala. Not something “bolted on”, which can’t be even used in all circumstances.
Please, just make the language symmetric in this regard.