Community
Participate
Working Groups
/* * Content assist ignores the bounds in bounded parameter type * * Note for the exemple: * In Eclipse preferences "Insert single proposal automatically" * and "hide proposal not visible in the incocation context" are set on. * */ class SuperClass { } class SubClass extends SuperClass { } public class GenericClass<T extends SuperClass> { public static void main(String[] args) { // Inserting "Gen" and invoking content assist it proposes: // "GenericClass<T>" and other possibility. // If I select "GenericClass<T>" the content assist inserts: GenericClass<SuperClass> // as it well be the only possibility, but also GenericClass<SubClass> // is a right proposal. // If I delete "SuperClass" inside angle brackets and invoke content // assist (inside angle brackets) it proposes "GenericClass" // (inside angle brackets) that is wrong. // If I digit an "S" it proposes: "SuperClass", "SubClass", // but also: "String" and several other actual parameter type // that cannot be inserted here. // It semmed completally ignoring the bounds of type parameter. } }
JDT Core reports the generic proposal.
(In reply to comment #0) [...] > class SuperClass { > > } > > class SubClass extends SuperClass { > > } > > public class GenericClass<T extends SuperClass> { > > public static void main(String[] args) { [...] > // If I delete "SuperClass" inside angle brackets and invoke content > // assist (inside angle brackets) it proposes "GenericClass" > // (inside angle brackets) that is wrong. If I understood right, you are completing in public class GenericClass<T extends CTRL+SPACE > { and accepting the GenericClass<T> proposal leads to public class GenericClass<T extends GenericClass<T>> { Other than being something you didn't intend, why would this be wrong ? > // If I digit an "S" it proposes: "SuperClass", "SubClass", > // but also: "String" and several other actual parameter type > // that cannot be inserted here. > // It semmed completally ignoring the bounds of type parameter. Where exactly is this completion being attempted ? Are you doing public class GenericClass<T extends SCTRL+SPACE> { If so, with HEAD I don't see anything wrong in the proposals I am seeing. Let me know if I have misunderstood your examples.
I did: 1. set caret (|) GenericClass<|> 2. Ctrl+Space
(In reply to comment #2) > (In reply to comment #0) > > [...] > > > class SuperClass { > > > > } > > > > class SubClass extends SuperClass { > > > > } > > > > public class GenericClass<T extends SuperClass> { > > > > public static void main(String[] args) { > > [...] > > > // If I delete "SuperClass" inside angle brackets and invoke content > > // assist (inside angle brackets) it proposes "GenericClass" > > // (inside angle brackets) that is wrong. > > > If I understood right, you are completing in > > public class GenericClass<T extends CTRL+SPACE > { I am completing inside the static main metod body, to create a local variable of type: GenericClass<SubClass>. So I write: class SuperClass { } class SubClass extends SuperClass { } public class GenericClass<T extends SuperClass> { public static void main(String[] args) { Gen CTRL+SPACE and system propose GenericClass<T> and other solutions I select GenericClass<T> and the system complete automatically in: GenericClass<SuperClass> but SuperClass is not the only solution, also SubClass is ok! now, if I delete SuperClass and ask a suggestion for actual parameter type: GenericClass<CTRL+SPACE> System complete in: GenericClass<GenericClass> that is wrong, the right choices for the actual parameter type are only SuperType and SubType. In fact if I complete the line with the local variable name: GenericClass<GenericClass> var; The system indicate type parameter <GenericClass> as wrong with the message: "Bound mismatch: The type GenericClass is not a valid substitute for the bounded parameter <T extends SuperClass> of the type GenericClass<T>" If I delete the wrong parameter, insert an S and ask again: GenericClass<S CTRL+SPACE> The system propose SuperClass, SubClass (it is ok) but also String and all other class that are out of bounds.
(In reply to comment #4) > (In reply to comment #2) > > (In reply to comment #0) [...] > > If I understood right, you are completing in > > > > public class GenericClass<T extends CTRL+SPACE > { > > > I am completing inside the static main metod body, to create a local variable > of type: GenericClass<SubClass>. > So I write: Thanks, the scenario is clear to me now.
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.