On 2011-06-03 19:44, Michael Shulman wrote: > On Fri, Jun 3, 2011 at 3:07 PM, Jonathan M Davis <jmdavisp...@gmx.com> wrote: > > I'd suggest opening a bug report. > > Okay, will do. > > > Regardless, I would have hoped that you'd get an error at compile > > time about overriding a non-virtual function if package is > > non-virtual > > It appears that overriding a non-virtual, non-abstract method (private > or package) just hides the base-class version when the reference is of > derived type, exactly as happens in C++ for non-virtual methods. E.g. > > class A { > private void dostuff() { writeln ("In A.dostuff"); } > } > > class B : A { > private void dostuff() { writeln ("In B.dostuff"); } > } > > void main () { > B y = new B(); > A x = y; > y.dostuff(); > x.dostuff(); > } > > prints > > In B.dostuff > In A.dostuff > > I would have kind of hoped for a compiler error too, given that C++ > programmers generally seem to feel that overriding non-virtual methods > in this way is a bad idea.
Try to compile with -w. My guess is that you will get a compiler error. But yes, it really should give an error regardless. - Jonathan M Davis