On Tue, 24 Nov 2009 07:38:51 -0500, Long Chang <[email protected]> wrote:

how about this case:


public interface Listener {
    void handleEvent (int);
}

class Test{
    this(){
        Listener listener    = new class() Listener {
            public void handleEvent(int evt) {
                toString(evt);
            }
        };
    }

    void toString(int evt){

    }
}

void main(){

}

---------------------------------------
x.d(17): Error: function object.Object.toString () does not match parameter
types (int)
x.d(17): Error: expected 0 arguments, not 1 for non-variadic function type
char[]()

Try outer.toString(evt).

Note that the anonymous class inherits from Object, which defines toString as:

char[] toString();

So the compiler thinks you are trying to call your anonymous class' toString, not the outer class' toString.

-Steve

Reply via email to