Bug 110799 - [1.5] Raw bindings miss type arguments but sometimes have type parameters
Summary: [1.5] Raw bindings miss type arguments but sometimes have type parameters
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.2 RC2   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-09-27 10:01 EDT by Markus Keller CLA
Modified: 2006-04-28 11:33 EDT (History)
2 users (show)

See Also:


Attachments
Proposed fix (1.97 KB, patch)
2006-04-24 11:34 EDT, Olivier Thomann CLA
no flags Details | Diff
Regression test (2.71 KB, patch)
2006-04-24 11:35 EDT, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.