[Issue 2524] final override inconsistent when implementing interfaces

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jan 20 10:25:28 PST 2009


http://d.puremagic.com/issues/show_bug.cgi?id=2524





------- Comment #8 from smjg at iname.com  2009-01-20 12:25 -------
(In reply to comment #7)
> In fact, private implies final (non-virtual), and does not put the function in
> the vtable (meaning it cannot override a base function).  From the spec: "All
> non-static non-private non-template member functions are virtual."

The sentence you've quoted states nothing about functions that _are_ private.

Moreover, a final method _can_ override a method in a base class.  Even so, an
interface has its own vtable, so the virtuality or not of a function with
respect to its class (or a class from which it is derived) should have nothing
to do with whether it can implement an interface method.

> If someone casts your class to an interface, do you want them to 
> now be able to call your private function?

Probably not.  But the way it's attempted in issue 2538 brings us back to the
problem of inheritance protection.  But we can talk about this there.


-- 



More information about the Digitalmars-d-bugs mailing list