Bug 110799

Summary: [1.5] Raw bindings miss type arguments but sometimes have type parameters
Product: [Eclipse Project] JDT Reporter: Markus Keller <markus.kell.r>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: eclipse, philippe_mulet
Version: 3.2   
Target Milestone: 3.2 RC2   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed fix
none
Regression test none

Description Markus Keller CLA 2005-09-27 10:01:40 EDT
I20050923-1000

Raw ITypeBindings don't deliver what the javadocs of getTypeArguments() and
getTypeParameters() tell.

public class Generic<E> {
}

class User {
    Generic raw;
    java.util.Collection rawCollection;
}

Currently, these values are returned:

Raw reference to source type Generic:
getTypeParameters() ==  { E }, getTypeArguments() == {}

Raw reference to binary type Collection:
getTypeParameters() ==  {}, getTypeArguments() == {}

I would expect these answers for both raw references:
getTypeParameters() == {}, getTypeArguments() == { Object }
Comment 1 Philipe Mulet CLA 2006-03-28 16:31:27 EST
Is this still an issue ?
Comment 2 Markus Keller CLA 2006-03-29 05:12:59 EST
Yes, has not been changed in HEAD compared to I20050923-1000.
Comment 3 Olivier Thomann CLA 2006-04-24 11:14:07 EDT
getTypeParameters() and getTypeArguments() should return an empty array in this case.
I willa adjust the specifications of getTypeArguments() and fix the implementation of getTypeParameters().
Patch to follow.

Philippe,

+1 for RC2?
Comment 4 Olivier Thomann CLA 2006-04-24 11:34:35 EDT
Created attachment 39293 [details]
Proposed fix
Comment 5 Olivier Thomann CLA 2006-04-24 11:35:09 EDT
Created attachment 39294 [details]
Regression test
Comment 6 Philipe Mulet CLA 2006-04-24 13:11:35 EDT
+1 for 3.2-RC2, assuming JDT/UI is ok with the change.
Comment 7 Olivier Thomann CLA 2006-04-24 13:53:33 EDT
Added org.eclipse.jdt.core.tests.dom.ASTConverter15Test.test0217.

An empty array is returned in all cases described in comment 0.
Fixed and released in HEAD.
Comment 8 Markus Keller CLA 2006-04-25 06:43:30 EDT
I'm OK with the code change for getTypeParameters() (unless we get test failures in the N-build, but I don't think we will ...).

However, I think the original API of ITypeBindings#getTypeArguments() would have been quite useful if it worked. E.g. here:

class Generic<E extends List<String>> { }
class User {
    Generic raw;
}

, I currently see no way to get at the type argument for E from the raw binding (a raw List here).
Comment 9 Olivier Thomann CLA 2006-04-27 23:09:33 EDT
Verified with I20060427-1600 for RC2.
Markus,
Why not using getTypeDeclaration() on the raw type binding.
Comment 10 Markus Keller CLA 2006-04-28 11:33:57 EDT
getTypeDeclaration() returns a generic binding, from which I can get the type parameters, but not the type arguments of the raw binding.

Since getErasure() on the individual type parameters also doesn't return raw types, I don't think there's currently a way to solve the puzzler in comment 7.