[Issue 3113] final overriding

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jun 16 07:59:09 PDT 2011


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


Steven Schveighoffer <schveiguy at yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |schveiguy at yahoo.com


--- Comment #8 from Steven Schveighoffer <schveiguy at yahoo.com> 2011-06-16 07:54:25 PDT ---
I think it is a bug.  If the case was that a final function could be masked by
a derived class, then this should compile:

module test;

enum A
{
    a = 0,
    b = 1
}

class BaseClass
{
    final A getEnum()
    {
        return A.a;
    }
}

class DerivedClass : BaseClass
{
    A getEnum()
    {
        return A.b;
    }
}

But I get the error:
bug3113.d(19): Error: function test.DerivedClass.getEnum cannot override final
function test.BaseClass.getEnum

This occurs even when I mark DerivedClass' function as final.

I was about to mark this as invalid, citing this as a better example, but since
the compiler complains about masking in this case, I don't see why the original
case is allowed.  I believe this kind of thing is allowed in C++.

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


More information about the Digitalmars-d-bugs mailing list