[Issue 10647] New: AutoImplement should implement overridden member functions with 'override' attributes

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jul 15 07:05:37 PDT 2013


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

           Summary: AutoImplement should implement overridden member
                    functions with 'override' attributes
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: ttanjo at gmail.com


--- Comment #0 from Tomoya Tanjo <ttanjo at gmail.com> 2013-07-15 07:05:36 PDT ---
The following code should be compiled with no error messages but it does not.

---
// It is like BlackHole but it also overrides non-virtual functions
string generateDoNothing(C, alias fun)() @property
{
    import std.traits;
    string stmt;

    static if (is(ReturnType!fun == void))
        stmt ~= "";
    else
    {
        string returnType = ReturnType!fun.stringof;
        stmt ~= "return "~returnType~".init;";
    }
    return stmt;
}

// A class to be overridden
class Foo{
    void bar(int a) { }
}

// Do nothing template
template DoNothing(Base)
{
    import std.typecons;
    alias DoNothing = AutoImplement!(Base, generateDoNothing, isAlwaysTrue);
}

template isAlwaysTrue(alias fun)
{
    enum isAlwaysTrue = true;
}

void main()
{
    auto foo = new DoNothing!Foo();
    foo.bar(13);
}
---

In dmd v2.064-devel-390a934 on Linux 64bit, it is compiled with the message
"Deprecation: overriding base class function without using override attribute
is deprecated".
The reason is that current AutoImplement implements overridden member functions
with 'override' attritubes only for the abstract functions.
It is the reason why WhiteHole and BlackHole work without depcerated messages.
They only override abstract functions.

-- 
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