www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1918] New: __traits(getVirtualFunctions) returns final functions

reply d-bugmail puremagic.com writes:

           Summary: __traits(getVirtualFunctions) returns final functions
           Product: D
           Version: 2.012
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: spec
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: dhasenan gmail.com

static assert(__traits(getVirtualFunctions, Object, "notifyRegister").length ==

That should succeed; Object.notifyRegister is final and therefore not virtual.

Clearer example:
class C
   final void foo(){}
static assert(__traits(getVirtualFunctions, C, "foo").length == 0);

That also fails.

Mar 12 2008
parent d-bugmail puremagic.com writes:

------- Comment #1 from dhasenan gmail.com  2008-11-16 08:22 -------
Okay, I've worked out how all this works.

__traits (getVirtualFunctions) gets all non-static methods.

__traits (isVirtualFunction) returns true iff the argument is a non-static

__traits (isFinalFunction) returns true iff __traits (isVirtualFunction)
returns true and the function is not marked final.

This is consistent, and 'fixing' the issues by changing features would result
in a loss of functionality.

This is not consistent with the expected meaning of "virtual function". I
request that the documentation for __traits be updated to include a definition
for "virtual function".

I also request that the keywords be changed to "getInstanceMethods" and
"isInstanceMethod" or something like that, for clarity.

Nov 16 2008