Bug 307499 - Content assist ignores the bounds in bounded parameter type
Summary: Content assist ignores the bounds in bounded parameter type
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5.2   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2010-03-30 05:05 EDT by Sergio Fiorentini CLA
Modified: 2023-12-16 19:24 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sergio Fiorentini CLA 2010-03-30 05:05:59 EDT
/*
 * 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.

    }
}
Comment 1 Dani Megert CLA 2010-03-30 06:59:56 EDT
JDT Core reports the generic proposal.
Comment 2 Srikanth Sankaran CLA 2010-03-30 08:00:17 EDT
(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.
Comment 3 Dani Megert CLA 2010-03-30 09:17:54 EDT
I did:
1. set caret (|) GenericClass<|>
2. Ctrl+Space
Comment 4 Sergio Fiorentini CLA 2010-03-30 14:50:56 EDT
(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.
Comment 5 Srikanth Sankaran CLA 2010-03-31 00:10:40 EDT
(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.
Comment 6 Eclipse Genie CLA 2019-12-30 03:53:27 EST
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.
Comment 7 Eclipse Genie CLA 2021-12-25 12:07:23 EST
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.
Comment 8 Eclipse Genie CLA 2023-12-16 19:24:40 EST
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.