www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2539] New: Base class methods are not envolved in interface methods implementation resolution

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

           Summary: Base class methods are not envolved in interface methods
                    implementation resolution
           Product: D
           Version: 2.022
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: 2korden gmail.com


Here is the code:

class A
{
    int b() { return 42; }
}

interface B
{
    int b();
}

class C : A, B
{
    // test.d(13): class test.C interface function B.b is not implemented
}

While it is usually not an issue, since you can simply add "int b() { return
super.b(); }" to class C, it is not in my case:

class A
{
    final int b() { return 42; } // note the 'final'
}

interface B
{
    int b();
}

class C : A, B
{
    int b() {
        return super.b();
    }
}

test.d(15): function test.C.b cannot override final function test.A.b

I believe this needs to be discussed.


-- 
Dec 22 2008
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2539


bugzilla digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID





This is working as designed. Base class methods are deliberately not considered
when adding interfaces to derived classes. As for it being final in the base
class, the base class designer gets to say what is final and what isn't for
base class methods. It would defeat the whole purpose to allow overriding a
final method.


-- 
Dec 25 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2539


smjg iname.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg iname.com
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |





This has cropped up again as issue 2565, where it has quite rightly been
changed to an enhancement request.  Changing to duplicate.


-- 
Jan 07 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2539


smjg iname.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |DUPLICATE







*** This bug has been marked as a duplicate of 2565 ***


-- 
Jan 07 2009