diff options
author | Jan Rieke <it@janrieke.de> | 2018-04-03 11:58:44 +0200 |
---|---|---|
committer | Jan Rieke <rieke@subshell.com> | 2018-04-05 18:42:53 +0200 |
commit | d586cc6b4fc1afb0a9e59e73ac3db1f5c914e191 (patch) | |
tree | e626683e24df84e6dc73de7d137e72b10e79c459 /src/core | |
parent | 1b38901064d7e53d4f4e7ab793031f56fe0a0000 (diff) | |
download | lombok-d586cc6b4fc1afb0a9e59e73ac3db1f5c914e191.tar.gz lombok-d586cc6b4fc1afb0a9e59e73ac3db1f5c914e191.tar.bz2 lombok-d586cc6b4fc1afb0a9e59e73ac3db1f5c914e191.zip |
wildcards for the builder() method
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/lombok/javac/handlers/HandleSuperBuilder.java | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/core/lombok/javac/handlers/HandleSuperBuilder.java b/src/core/lombok/javac/handlers/HandleSuperBuilder.java index 73271cba..2d844432 100644 --- a/src/core/lombok/javac/handlers/HandleSuperBuilder.java +++ b/src/core/lombok/javac/handlers/HandleSuperBuilder.java @@ -29,6 +29,7 @@ import java.util.ArrayList; import org.mangosdk.spi.ProviderFor; +import com.sun.tools.javac.code.BoundKind; import com.sun.tools.javac.code.Flags; import com.sun.tools.javac.tree.JCTree; import com.sun.tools.javac.tree.JCTree.JCAnnotation; @@ -45,6 +46,7 @@ import com.sun.tools.javac.tree.JCTree.JCStatement; import com.sun.tools.javac.tree.JCTree.JCTypeApply; import com.sun.tools.javac.tree.JCTree.JCTypeParameter; import com.sun.tools.javac.tree.JCTree.JCVariableDecl; +import com.sun.tools.javac.tree.JCTree.JCWildcard; import com.sun.tools.javac.util.List; import com.sun.tools.javac.util.ListBuffer; import com.sun.tools.javac.util.Name; @@ -525,7 +527,17 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> { JCBlock body = maker.Block(0, List.<JCStatement>of(statement)); int modifiers = Flags.PUBLIC; modifiers |= Flags.STATIC; - return maker.MethodDef(maker.Modifiers(modifiers), type.toName(builderMethodName), namePlusTypeParamsToTypeReference(maker, type.toName(builderClassName), typeParams), copyTypeParams(source, typeParams), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null); + + // Add any type params of the annotated class to the return type. + ListBuffer<JCExpression> typeParameterNames = new ListBuffer<JCExpression>(); + typeParameterNames.addAll(typeParameterNames(maker, typeParams)); + // Now add the <?, ?>. + JCWildcard wildcard = maker.Wildcard(maker.TypeBoundKind(BoundKind.UNBOUND), null); + typeParameterNames.add(wildcard); + typeParameterNames.add(wildcard); + JCTypeApply returnType = maker.TypeApply(maker.Ident(type.toName(builderClassName)), typeParameterNames.toList()); + + return maker.MethodDef(maker.Modifiers(modifiers), type.toName(builderMethodName), returnType, copyTypeParams(source, typeParams), List.<JCVariableDecl>nil(), List.<JCExpression>nil(), body, null); } public void generateBuilderFields(JavacNode builderType, java.util.List<BuilderFieldData> builderFields, JCTree source) { |