digitalmars.D.bugs - [Issue 559] New: Final has no effect on methods
- d-bugmail puremagic.com (27/27) Nov 18 2006 http://d.puremagic.com/issues/show_bug.cgi?id=559
- d-bugmail puremagic.com (7/9) Nov 21 2006 And it does not override, due to the presence of 'final'. It creates a n...
- d-bugmail puremagic.com (28/28) Dec 03 2006 http://d.puremagic.com/issues/show_bug.cgi?id=559
- d-bugmail puremagic.com (9/9) Jul 01 2007 http://d.puremagic.com/issues/show_bug.cgi?id=559
- d-bugmail puremagic.com (5/5) Jul 23 2007 http://d.puremagic.com/issues/show_bug.cgi?id=559
http://d.puremagic.com/issues/show_bug.cgi?id=559
Summary: Final has no effect on methods
Product: D
Version: 0.174
Platform: PC
URL: http://www.digitalmars.com/d/function.html
OS/Version: Windows
Status: NEW
Keywords: accepts-invalid, diagnostic
Severity: major
Priority: P2
Component: DMD
AssignedTo: bugzilla digitalmars.com
ReportedBy: deewiant gmail.com
class Base {
final void foo() {}
}
class Derived : Base {
void foo() {}
}
This compiles fine, although "Functions marked as final may not be overridden
in a derived class".
Changing Derived.foo to override void foo() {} makes DMD bark:
asdf.d(7): function asdf.Derived.foo function foo does not override any
With or without override, DMD should say "function asdf.Derived.foo cannot
override final function asdf.Base.foo" or something to that effect.
--
Nov 18 2006
http://d.puremagic.com/issues/show_bug.cgi?id=559This compiles fine, although "Functions marked as final may not be overridden in a derived class".And it does not override, due to the presence of 'final'. It creates a new have an effect on methods. If it's the best behavior that's another story, but it's not against the spec I believe. --
Nov 21 2006
http://d.puremagic.com/issues/show_bug.cgi?id=559
deewiant gmail.com changed:
What |Removed |Added
----------------------------------------------------------------------------
OtherBugsDependingO| |511
nThis| |
Keywords| |spec
It is against the spec. See http://www.digitalmars.com/d/function.html, under
"Virtual Functions": "Functions marked as final may not be overridden in a
derived class, unless they are also private. For example:"
class A
{
int def() { ... }
final int foo() { ... }
final private int bar() { ... }
private int abc() { ... }
}
class B : A
{
int def() { ... } // ok, overrides A.def
int foo() { ... } // error, A.foo is final
int bar() { ... } // ok, A.bar is final private, but not virtual
int abc() { ... } // ok, A.abc is not virtual, B.abc is virtual
}
The relevant bit is the comment "error, A.foo is final". This code compiles
without a problem, yet according to the spec it shouldn't.
--
Dec 03 2006
http://d.puremagic.com/issues/show_bug.cgi?id=559
bugzilla digitalmars.com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
Fixed DMD 1.018 and DMD 2.002
--
Jul 01 2007
http://d.puremagic.com/issues/show_bug.cgi?id=559 test case: http://dstress.kuehne.cn/nocompile/final_01.d --
Jul 23 2007









d-bugmail puremagic.com 