www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4679] New: Problem with final & override

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4679

           Summary: Problem with final & override
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



This D2 program compiles and runs with DMD 2.048 with no errors:


import std.c.stdio: puts;
class Base {
    this() { foo(); }
    private void foo() { puts("Base.foo"); } // called
}
class Derived : Base {
    private override void foo() { // not called
        puts("Derived.foo");
        super.foo();
    }
}
void main() {
    auto d = new Derived();
}


Output:
Base.foo


If Base.foo() is private then it's final. Then what is Derived.foo()
overriding?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 19 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4679


Jonathan M Davis <jmdavisProg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jmdavisProg gmail.com



15:39:49 PDT ---
The fact that private has anything to do with final is arguably a bug. It
certainly contradicts TDPL. The bug on that is
http://d.puremagic.com/issues/show_bug.cgi?id=4542

Now, this is still a bug. Either dmd still makes private final, at which point
overriding the method should be a bug, or it follows TDPL and does not make it
final, at which point, the derived method should be called, which it isn't. So,

derived method rather than making overriding the method an error.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 19 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4679


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |andrej.mitrovich gmail.com
         Resolution|                            |FIXED



21:28:55 PDT ---
Private methods are now final by default and OP sample errors. Whether or not
that will change (probably not) depends on Issue 4542.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 21 2012