Bug 13798 – Suggestions for classes and methods that can be final

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2014-11-30T10:54:58Z
Last change time
2024-12-13T18:36:59Z
Assigned to
No Owner
Creator
bearophile_hugs
Moved to GitHub: dmd#17688 →

Comments

Comment #0 by bearophile_hugs — 2014-11-30T10:54:58Z
I suggest to add a compiler tip (enabled with warnings) that suggests the programmer to add a "final" to methods and to classes definitions like this that don't need to be virtual, to avoid some virtual calls: class Bar {} class Foo : Bar {} void main() {} This is similar to the -Wsuggest-final-types and -Wsuggest-final-methods warnings of G++ 5.0, that also tells how many virtual calls are avoided: /aux/hubicka/firefox/docshell/base/nsDocShell.h:124:0: warning: Declaring type ‘struct nsDocShell’ final would enable devirtualization of 216 calls [-Wsuggest-final-types] class nsDocShell : public nsDocLoader, ^
Comment #1 by robert.schadek — 2024-12-13T18:36:59Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17688 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB