[JBoss JIRA] (ROASTER-135) Types.toResolvedType does not resolve types with wildcard correctly
by George Gastaldi (Jira)
[ https://issues.redhat.com/browse/ROASTER-135?page=com.atlassian.jira.plug... ]
George Gastaldi reassigned ROASTER-135:
---------------------------------------
Assignee: Viktor Micsko
> 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
> Assignee: Viktor Micsko
> Priority: Major
> Fix For: 2.21.2.Final
>
>
> (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)