]
Yusuf Iskenderoglu commented on ROASTER-48:
-------------------------------------------
Sorry, I accidentally categorized this as a "Feature Request", however actually
it is a bug.
Because it is currently impossible to use a Type-Parameter as a method parameter type.
A generic parameterized Method is not possible. Class<T> gets
reduced to Class, generic parameter name is not accepted
----------------------------------------------------------------------------------------------------------------------
Key: ROASTER-48
URL:
https://issues.jboss.org/browse/ROASTER-48
Project: Roaster
Issue Type: Bug
Reporter: Yusuf Iskenderoglu
What I need is something like this:
{code}
final MethodSource<JavaClassSource> newMethod =
to.addMethod()
.setName(name)
.setPublic()
.setFinal(true);
newMethod.addTypeVariable("T");
newMethod.setReturnType("T").setBody(localBody
+ ".as(((Class<T>) as));");
newMethod.addParameter(int.class, "index");
newMethod.addParameter("Class<T>",
"as");
{code}
However, roaster reduces *Class<T>* to *Class*. In that case, the method returns
only "Object", because the type information cannot be deduced anymore, causes
ugly Code on the caller side:
{code}
app().financing.desires(0, Foo.class).programNumber;
vs.
Foo k = (Foo) app().financing.desires(0, Foo.class);
k.programNumber
{code}
Further, a parameter with the name *T* is not accepted at all, even if its defined as a
type variable.
Would be very nice, if you could solve this issue :-)