Community
Participate
Working Groups
Created attachment 255207 [details] Demo project (containing the visitor and logic to create the example project) (Might be related to #472617 ???) Example code: public class R2 { void l() { C c1 = new C(); c1.a(a -> { new Object() { }; // [1] }); C c2 = new C(); c2.a(new Consumer<Object>() { // [2] @Override public void accept(Object t) { } }); } } class C { void a(Consumer<?> d) { } } Applying following visitor to this example program allows to construct the type hierarchy of the anonymous class of "new Consumer<Object>() { ... }": class AnonymousClassVisitor extends ASTVisitor { public boolean visit(AnonymousClassDeclaration typeDeclaration) { IType type = (IType) typeDeclaration.resolveBinding().getJavaElement(); ITypeHierarchy newSupertypeHierarchy = type.newSupertypeHierarchy(new NullProgressMonitor()); IType superclass = newSupertypeHierarchy.getSuperclass(type); /* [3] */ } } At [3], superclass is null, when handling the anonymous class declaration denoted with [2]. The strange thing is that it is only null, if the anonymous class declaration denoted with [1] is handled before. If you remove line [1] or only remove the curly braces (so that 'new C(){};' becomes 'new C();'), superclass at [3] is well 'java.lang.Object' when handling [2]. The attachment contains demo code for this problem, providing logic to create the demo project in the runtime eclipse and applying the mentioned visitor.
This might be related to anonymous type occurrence count. Will take a look during 4.7.
Bulk move out of 4.8
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.