Thread overview
[Issue 419] New: Anonymous classes are not working.
Oct 09, 2006
d-bugmail
Oct 18, 2006
d-bugmail
Oct 21, 2006
Thomas Kuehne
October 09, 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@digitalmars.com
        ReportedBy: benoit@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


-- 

October 18, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=419


bugzilla@digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Comment #1 from bugzilla@digitalmars.com  2006-10-18 13:27 -------
Fixed DMD 0.170


-- 

October 21, 2006
d-bugmail@puremagic.com schrieb am 2006-10-09:
> http://d.puremagic.com/issues/show_bug.cgi?id=419

> 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*

<snip>

Added to DStress as http://dstress.kuehne.cn/run/t/this_13_A.d http://dstress.kuehne.cn/run/t/this_13_B.d http://dstress.kuehne.cn/run/t/this_13_C.d

Thomas