2013/2/23 deadalnix <deadalnix@gmail.com>
On Friday, 22 February 2013 at 17:25:58 UTC, kenji hara wrote:
2013/2/23 deadalnix <deadalnix@gmail.com>

On Friday, 22 February 2013 at 15:32:42 UTC, kenji hara wrote:

Yes, then the B's definition should raise "mutable A.foo() is not
overridden but hidden in B" (but doesn't because of bug 8366).


I don't really understand why adding a special case for something that has
no real use case.


In old age, it had thrown HiddenFuncError in runtime, and some years ago,
it had been changed to compile-time error.
It is one of design in D to avoid unintended method hiding issue.


This whole overload on const (note overload, not override) has been introduced in the first place to solve problem that inout now solve in a superior way.

No, const/inout overload does not intend to solve 'method hiding' problem.

To clarify the situation, I try to explain.

class A {
  void foo() {}
  void foo() const {}
}
class B : A {
  override void foo() const {} // or inout
}

In above, B.foo does override _only_one_ vtbl entry, that is for A.foo() const.
Then in B's vtbl, another entry for mutable A.foo() is *never* filled. We call the state "B.foo() const hides mutable A.foo()". (If you really inherit mutable A.foo() in B, you should use alias declaration, "alias super.foo foo;")

Here you should be aware that, the B.foo() const fills just only one vtbl entry.
Even if B.foo() const has covariant signature with both A.foo() and A.foo() const, it never fill two vtbl entries for them.
It's not allowed.

Kenji Hara