[Issue 419] New: Anonymous classes are not working.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Oct 9 14:27:35 PDT 2006


http://d.puremagic.com/issues/show_bug.cgi?id=419

           Summary: Anonymous classes are not working.
           Product: D
           Version: 0.169
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: benoit at tionex.de


interface I {
    void get( char[] s );
}
class C{
    void init(){
        I i = new class() I {
            void get( char[] s ){
                func();  // line 8
            }
        };
    }
    void func( ){ }
}
void main(){
}

an.d(8): this for func needs to be type C not type void*
See also: http://www.digitalmars.com/d/class.html#anonymous

Doing that line
        I i = new class() { // without the "I"
gives this nice message:
an.d(8): this for func needs to be type C not type void*
an.d(6): cannot implicitly convert expression ((class __anonclass1 : Object
{
    void get(char[] s)
{
assert(this,"null this");
((this.this).func)();
}
    void* this;
}
) , new __anonclass1) of type an.C.init.__anonclass1 to an.I


-- 




More information about the Digitalmars-d-bugs mailing list