Bug 153323 - better view of generic type information
Summary: better view of generic type information
Status: RESOLVED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.2   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2006-08-09 13:37 EDT by Jon Barrilleaux CLA
Modified: 2009-08-30 02:09 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jon Barrilleaux CLA 2006-08-09 13:37:02 EDT
This is a pretty vague request, but I am having troubling seeing the actual "resolved" type for generic parameters and return values.  Given the complexities of generics I would be surprised if others are not having similar problems.

The compiler resolves the type and complains, but I have yet to figure out how to get Eclipse to show me the resolved generic type so that I can figure out what is wrong, or why the type is not being resolved the way I think it should be resolved.

For example,

MyClass<C extends Collection> {
    public C getValues() {
    }
}

MySetClass extends MyClass<Set> {
}

MySetClass mySet;
Set set = mySet.getValues(); // error!

The return value from mySet.getValues() must be cast to Set.  Seems that it should resolve to Set, not Collection.  No doubt this has something to do with with the erased type, but it would great if Eclipse could show as much info as it could about how generic types are being "resolved".
Comment 1 Martin Aeschlimann CLA 2006-08-10 07:14:54 EDT
But your code example compiles, I don't get an error at the location you noted it.

I think what's helpful here is the hover over 'getValues'. It shows that after all substitutions the actual signature is 'Set getValues()'. Is that whay you wanted?

-----------------------------
import java.util.Collection;
import java.util.Set;

public class MyClass<C extends Collection> {
    public C getValues() {
	return null;
    }
}

class MySetClass extends MyClass<Set> {
}

class V {
	MySetClass mySet;
	Set set = mySet.getValues();
}


Comment 2 Jon Barrilleaux CLA 2006-08-10 11:05:46 EDT
I just cobbled the example together from a much more complicated situation that prompted my request.  I thought I had captured the essence of the problem but evidently not.  If nothing else, this gets to the heart of the matter in that the hovers in my situation show that the type resolves to Collection, not Set, and I could never get an adequate "picture" of what is going on with regard to type resolution.

Perhaps it would be helpful if the Outline view (or some more advanced view, such as a context sensitive "type" view) were able to show the resolved types instead of the declared generic type, or offered options of what to show -- declared, resolved, erased, ???.  The more I use generics the more I find these odd situations where I can't quite figure out why the compiler is doing what it does.

In any case, thanks for considering my rather vague request.
Comment 3 Denis Roy CLA 2009-08-30 02:09:25 EDT
As of now 'LATER' and 'REMIND' resolutions are no longer supported.
Please reopen this bug if it is still valid for you.