Community
Participate
Working Groups
HEAD - create an AST for org.eclipse.jdt.internal.core.search.matching.MatchLocator - resolve the type binding for the anonymous type inside #createAndPattern(SearchPattern, SearchPattern) => ITypeBinding#getJavaElement() on that anonymous type returns: ResolvedSourceField: org.eclipse.jdt.internal.core.search.matching.MatchLocator.createAndPattern(...).new AndPattern() {...}.current : SearchPattern => Expected: the IType for the anonymous class, not an IField inside the type. Consequently, getJavaElement() on e.g. the variable binding for field 'current' throws a java.lang.ClassCastException: org/eclipse/jdt/internal/core/ResolvedSourceField incompatible with org/eclipse/jdt/core/IType at org.eclipse.jdt.core.dom.VariableBinding.getUnresolvedJavaElement(VariableBinding.java:139) at org.eclipse.jdt.core.dom.VariableBinding.getJavaElement(VariableBinding.java:128) This bug is a problem for the Infer Type Arguments refactoring.
Philippe, can you please have a look. The bug is blocking Markus in Infer Type Argument fixing...
Reduced the test case to: public class X { void foo() { new Y(0/*c*/) { Object field; }; } } class Y { Y(int i) { } } Note that if you remove /*c*/, you get a ResolvedSourceType for the anonymous.
Changed Parser#consumeAnonymousClassBody() to flush comments (as this is already done for type headers. Added regression test ASTModelBridgeTests#testAnonymous2()
Verified in i20050527-0010