aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Rieke <it@janrieke.de>2018-04-15 19:31:02 +0200
committerJan Rieke <it@janrieke.de>2018-04-15 19:31:02 +0200
commitf13f5c697385fde8c3833c47786909deba2833ce (patch)
tree26127956f7510470fbb4844dbeaef8a7d233ff35
parent24a6c3354104e73874e8641f93517924a2f6d760 (diff)
downloadlombok-f13f5c697385fde8c3833c47786909deba2833ce.tar.gz
lombok-f13f5c697385fde8c3833c47786909deba2833ce.tar.bz2
lombok-f13f5c697385fde8c3833c47786909deba2833ce.zip
use superclass generics for abstract builder class' extends clause
-rw-r--r--src/core/lombok/javac/handlers/HandleSuperBuilder.java13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/core/lombok/javac/handlers/HandleSuperBuilder.java b/src/core/lombok/javac/handlers/HandleSuperBuilder.java
index 893f38d4..740b8e89 100644
--- a/src/core/lombok/javac/handlers/HandleSuperBuilder.java
+++ b/src/core/lombok/javac/handlers/HandleSuperBuilder.java
@@ -37,6 +37,7 @@ import com.sun.tools.javac.tree.JCTree.JCBlock;
import com.sun.tools.javac.tree.JCTree.JCClassDecl;
import com.sun.tools.javac.tree.JCTree.JCExpression;
import com.sun.tools.javac.tree.JCTree.JCFieldAccess;
+import com.sun.tools.javac.tree.JCTree.JCIdent;
import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
import com.sun.tools.javac.tree.JCTree.JCMethodInvocation;
import com.sun.tools.javac.tree.JCTree.JCModifiers;
@@ -358,10 +359,14 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
injectMethod(typeNode, constr, null, Javac.createVoidType(typeNode.getSymbolTable(), CTC_VOID));
}
- private ListBuffer<JCExpression> getTypeParamExpressions(List<JCTypeParameter> typeParams, JavacTreeMaker maker) {
+ private ListBuffer<JCExpression> getTypeParamExpressions(List<? extends JCTree> typeParams, JavacTreeMaker maker) {
ListBuffer<JCExpression> typeParamsForBuilderParameter = new ListBuffer<JCExpression>();
- for (JCTypeParameter typeParam : typeParams) {
- typeParamsForBuilderParameter.add(maker.Ident(typeParam.getName()));
+ for (JCTree typeParam : typeParams) {
+ if (typeParam instanceof JCTypeParameter) {
+ typeParamsForBuilderParameter.add(maker.Ident(((JCTypeParameter)typeParam).getName()));
+ } else if (typeParam instanceof JCIdent) {
+ typeParamsForBuilderParameter.add(maker.Ident(((JCIdent)typeParam).getName()));
+ }
}
return typeParamsForBuilderParameter;
}
@@ -583,7 +588,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
if (superclassBuilderClassExpression != null) {
// If the annotated class extends another class, we want this builder to extend the builder of the superclass.
// 1. Add the type parameters of the superclass.
- typeParamsForBuilder = getTypeParamExpressions(typeParams, maker);
+ typeParamsForBuilder = getTypeParamExpressions(superclassTypeParams, maker);
// 2. Add the builder type params <C, B>.
typeParamsForBuilder.add(maker.Ident(tdParent.toName("C")));
typeParamsForBuilder.add(maker.Ident(tdParent.toName("B")));