[JBoss JIRA] (ROASTER-135) Types.toResolvedType does not resolve types with wildcard correctly
by Viktor Micsko (Jira)
Viktor Micsko created ROASTER-135:
-------------------------------------
Summary: Types.toResolvedType does not resolve types with wildcard correctly
Key: ROASTER-135
URL: https://issues.redhat.com/browse/ROASTER-135
Project: Roaster
Issue Type: Bug
Components: API
Affects Versions: 2.21.1.Final
Reporter: Viktor Micsko
(2.21.2.Final and 2.21.3-SNAPSHOT are also affected)
https://github.com/forge/roaster/blob/master/api/src/main/java/org/jboss/...
Types.toResolvedType joins the generic parts using comma as follows:
{code:java}
if (Types.isGeneric(type))
{
StringJoiner genericJoiner = new StringJoiner(",");
for (String genericPart : Types.splitGenerics(type))
{
genericJoiner.add(toResolvedType(genericPart, importer));
}
builder.append("<").append(genericJoiner.toString()).append(">");
}
{code}
This behaviour is incorrect for types like List<? extends Number>.
It also leads to the following being incorrectly generated as void return type for such types:
{code:java}
Type<JavaInterfaceSource> returnType = ...
MethodSource<JavaClassSource> method = ...
destinationMethod.setReturnType(returnType);
{code}
A simple fix would be:
{code:java}
if (Types.isGeneric(type))
{
StringJoiner genericJoiner = new StringJoiner(",");
for (String genericPart : Types.splitGenerics(type))
{
genericJoiner.add(toResolvedType(genericPart, importer));
}
String genericParts = genericJoiner.toString();
genericParts = genericParts.replace("?extends", "? extends ");
genericParts = genericParts.replace("?super", "? super ");
builder.append("<").append(genericParts).append(">");
}
{code}
--
This message was sent by Atlassian Jira
(v7.13.8#713008)
4 years, 7 months
[JBoss JIRA] (ROASTER-134) MyClassA<String>.MyClassB as returnType isn't working
by Thorsten Groß (Jira)
Thorsten Groß created ROASTER-134:
-------------------------------------
Summary: MyClassA<String>.MyClassB as returnType isn't working
Key: ROASTER-134
URL: https://issues.redhat.com/browse/ROASTER-134
Project: Roaster
Issue Type: Bug
Affects Versions: 2.21.1.Final
Reporter: Thorsten Groß
Attachments: Testcase.java
.addMethod.setReturnType("MyClassA<String>.MyClassB") isn't working.
The behavior is different and depends on the declaration of the imports. I wrote a small example
TESTCASE1
---------
package com.test;
import MyClassA.MyClassB;
public class Test {
/**
* Expected returntype: MyClassA<String>.MyClassB
*/
MyClassB<String> method() {
return null;
}
}
TESTCASE2
---------
package com.test;
import com.test.MyClassA;
import com.test.MyClassA.MyClassB;
public class Test {
/**
* Expected returntype: MyClassA<String>.MyClassB
*/
MyClassA.MyClassB<String> method() {
return null;
}
}
--
This message was sent by Atlassian Jira
(v7.13.8#713008)
4 years, 7 months