Community
Participate
Working Groups
In the code snippet below, ctrl-space expansion fails at the comment. The code compiles and runs correctly. public class Context { private int value = 10; public abstract class Callback { public abstract void doit(int value) {} } } public class ContextTest { private Context context = new Context(); public void test() { context.new Callback() { public void doit(int value) { Set foo = new HashSet(); foo. // expansion fails here with message in status bar: // "Callback cannot be resolved to a type" } } } }
*** Bug 132703 has been marked as a duplicate of this bug. ***
The code does not really compile. But I can reproduce even with the obvious fixes applied (abstract method has no body, add imports, add missing ";").
Another item on this. I also have a non-inner abstract class called Callback in the same package as the Context. If I control-click/open-declaration on the Callback from within ContextTest, the outer Callback class is opened instead of the inner Callback class.
I do not reproduce the bug in I20090407-1430. I close this bug as WORKSFORME.
Version: 3.5.0 Build id: I20090428-0100 I can reproduce the problem by fixing the compile errors (delete abstract method body, add imports, fix semicolon etc) Here is a simpler test case you can paste into the explorer: import java.util.HashSet; import java.util.Set; class Context { private int value = 10; public abstract class Callback { public abstract void doit(int value); } } public class ContextTest { private Context context = new Context(); public void test() { Set foo = new HashSet(); // completion works here after "foo." context.new Callback() { public void doit(int value) { Set foo = new HashSet(); // completion does not work here after "foo." } }; } }
I also reproduce the problem now. I probably do not use the right test case before.
Created attachment 134615 [details] Proposed patch The problem is in recovery and not only in completion. The receiver of the anonymous must be attached earlier to the allocation expression to be taken into account by the recovery. This patch modify the grammar so parser files must be generated
+1. Patch looks good.
Released for 3.5RC1. Tests added DietRecoveryTest#test126() CompletionTests#testBug132679()
*** Bug 274020 has been marked as a duplicate of this bug. ***
Verified for 3.5RC1 using I20090511-2000.