Community
Participate
Working Groups
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".
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(); }
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.
As of now 'LATER' and 'REMIND' resolutions are no longer supported. Please reopen this bug if it is still valid for you.