Community
Participate
Working Groups
If an ITD method is declared on an interface with an anonymous inner class returned as the result, the compiler generates an error for any "super.xxx" calls in the anonymous inner class. The example project shows this with a nested inner interface, but the same problem occurs with an ITD of this kind on any interface. The error does not occur if the ITD is declared on an inner class (as shown in the example) or a normal class.
Created attachment 19507 [details] Test project Test case attached
take a look for M3
Collapsed into one test program: class MyClass { protected Object method() { return null; } } abstract aspect A { interface C2 { } public void C2.hello() { new MyClass() { protected Object methodX() { return super.method(); } }; } // ok class C { } public void C.hello() { new MyClass() { protected Object methodX() { return super.method(); } }; } }
putting on my todo list, testcase added to CVS.
When we fail, at the top of MessageSend.resolveType(BlockScope) we attempt receiverType.resolveType() and the receiverType is an InterSuperReference. When we succeed it is simply a normal SuperReference. When the ITD is on an interface we run a 'InterSuperFixerVisitor' over the body of the ITD. (see InterTypeDeclaration.fixSuperCallsForInterfaceContext). Unfortunately it doesn't seem to realise when we've moved into an inner anonymous class (blurgh). I modified the visitor to keep a stack counter when it goes into local types - if its >0 we don't mess with the super calls. fix checked in, waiting on build.
fix available.