Community
Participate
Working Groups
Build id: I20090313-0100 (3.5 M6) 1. Create a java project containing: package test; public final class TestClass {} interface TestInterface {} class Subclass extends test.Test|{} 2. At the '|' symbol do CTRL+SPACE. You will see the token Test being completed into test.TestInterface This proposal is bad and leads to an immediate error (super class must be a class error)
This is not reproducible in 3.5-M7.
(In reply to comment #1) > This is not reproducible in 3.5-M7. Can you check again ? I could reproduce this with Eclipse SDK Version: 3.5.0 Build id: I20090430-2300 which is M7 as well as with HEAD.
Interesting .... when I have all these in the same compilation unit, I am able to reproduce it. But, if I create a project, add a package test, add TestClass, TestInterface, SubClass one after another (thus there are three compilation units), I am not able to reproduce this. So apparently this has something to do with all the types being in the same compilation unit.
Created attachment 137046 [details] Code plugin patch - v0.5 Patch for plugin org.eclipse.jdt.core, class CompletionEngine.
Created attachment 137048 [details] Tests plugin patch - v0.5 Patch for plugin org.eclipse.jdt.core.tests.model - added two tests to CompletionTests.
There was one place where it was looping over the top-level types in a compilation unit where a few validation checks were missing. That also explains why it was reproducible only when the class and interface are in the same compilation unit. While at it, I also fixed a related problem where the type itself (ie SubClass in this case) was being offered as a completion choice. Thus the attached code patch fixes two issues: (1) the original problem described in this bug and (2) the problem where the type itself is offered as a choice for completion. The attached tests patch has one test each for the two problems listed above.
Created attachment 137831 [details] Code plugin patch - v0.6 Added another patch with one additional change to cater to another scenario which is the flip-side of the original problem. This patch, in addition to fixing issues #1, #2 also fixes: (3) A class is being offered as a choice for the interface.
Created attachment 137832 [details] Tests plugin patch - v0.6 Added an additional test - altogether 3 tests including the 2 new tests in the previous patch, to ensure that a Class is not being offered as a choice when expecting an Interface.
Released in HEAD for 3.6M1 (after minor clean up)
Verified for 3.6M1 using build 20090802-2000.