Bug 10647 – AutoImplement should implement overridden member functions with 'override' attributes
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-07-15T07:05:00Z
Last change time
2013-07-17T06:33:15Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
ttanjo
Comments
Comment #0 by ttanjo — 2013-07-15T07:05:36Z
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.