Lately I've found out that this works, although I'd expect it not to:
class Outer
{
Button b;
void foo() {}
void bar()
{
b = new Button();
b.setOnClickListener(new OnClickListener(){
@Override
public void OnClick()
{
foo();
}
});
}
}
I'd expect Outer.this.foo() to be required, but seems that simply foo() also works. Could someone tell me when exactly this was added to the language? Please help me understand exact name resolution rules here. Thanks!
The questions:
1) Why is this working?
2) If this works, why do we need the "Outer.this" syntax?