[JBoss JIRA] (ROASTER-48) A generic parameterized Method is not possible. Class<T> gets reduced to Class, generic parameter name is not accepted
by George Gastaldi (JIRA)
[ https://issues.jboss.org/browse/ROASTER-48?page=com.atlassian.jira.plugin... ]
George Gastaldi closed ROASTER-48.
----------------------------------
Fix Version/s: 2.19.0.Final
(was: 2.x Future)
Resolution: Done
I have pushed a fix to the master branch. Can you give it a try and provide some feedback?
Thank you!
> A generic parameterized Method is not possible. Class<T> gets reduced to Class, generic parameter name is not accepted
> ---------…
[View More]-------------------------------------------------------------------------------------------------------------
>
> Key: ROASTER-48
> URL: https://issues.jboss.org/browse/ROASTER-48
> Project: Roaster
> Issue Type: Bug
> Reporter: Yusuf Iskenderoglu
> Assignee: George Gastaldi
> Fix For: 2.19.0.Final
>
>
> 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 :-)
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)
[View Less]