Thread overview |
---|
November 18, 2006 [Issue 559] New: Final has no effect on methods | ||||
---|---|---|---|---|
| ||||
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. -- |
November 22, 2006 [Issue 559] Final has no effect on methods | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=559 ------- Comment #1 from brunodomedeiros+bugz@gmail.com 2006-11-21 18:00 ------- >This 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 method lineage, similar to C# 'new' in a method declaration, thus 'final' does have an effect on methods. If it's the best behavior that's another story, but it's not against the spec I believe. -- |
December 03, 2006 [Issue 559] Final has no effect on methods | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=559 deewiant@gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- OtherBugsDependingO| |511 nThis| | Keywords| |spec ------- Comment #2 from deewiant@gmail.com 2006-12-03 05:03 ------- 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. -- |
July 01, 2007 [Issue 559] Final has no effect on methods | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=559 bugzilla@digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED ------- Comment #3 from bugzilla@digitalmars.com 2007-07-01 13:26 ------- Fixed DMD 1.018 and DMD 2.002 -- |
July 23, 2007 [Issue 559] Final has no effect on methods | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=559 ------- Comment #4 from thomas-dloop@kuehne.cn 2007-07-23 14:56 ------- test case: http://dstress.kuehne.cn/nocompile/final_01.d -- |
Copyright © 1999-2021 by the D Language Foundation