aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/lombok/javac/handlers/HandleSuperBuilder.java15
-rw-r--r--test/transform/resource/after-delombok/SuperBuilderNestedGenericTypes.java41
-rw-r--r--test/transform/resource/after-ecj/SuperBuilderNestedGenericTypes.java37
-rw-r--r--test/transform/resource/before/SuperBuilderNestedGenericTypes.java12
4 files changed, 99 insertions, 6 deletions
diff --git a/src/core/lombok/javac/handlers/HandleSuperBuilder.java b/src/core/lombok/javac/handlers/HandleSuperBuilder.java
index c9df4811..5f4f3c1d 100644
--- a/src/core/lombok/javac/handlers/HandleSuperBuilder.java
+++ b/src/core/lombok/javac/handlers/HandleSuperBuilder.java
@@ -53,6 +53,7 @@ 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.Context;
import com.sun.tools.javac.util.List;
import com.sun.tools.javac.util.ListBuffer;
import com.sun.tools.javac.util.Name;
@@ -414,7 +415,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
allTypeParams.add(maker.TypeParameter(tdParent.toName(classGenericName), List.<JCExpression>of(annotatedClass)));
// 2. The return type for all setter methods, named "B", which extends this builder class.
Name builderClassName = tdParent.toName(builderClass);
- ListBuffer<JCExpression> typeParamsForBuilder = getTypeParamExpressions(typeParams, maker);
+ ListBuffer<JCExpression> typeParamsForBuilder = getTypeParamExpressions(typeParams, maker, source.getContext());
typeParamsForBuilder.add(maker.Ident(tdParent.toName(classGenericName)));
typeParamsForBuilder.add(maker.Ident(tdParent.toName(builderGenericName)));
JCTypeApply typeApply = maker.TypeApply(namePlusTypeParamsToTypeReference(maker, tdParent, builderClassName, false, List.<JCTypeParameter>nil()), typeParamsForBuilder.toList());
@@ -424,7 +425,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(superclassTypeParams, maker);
+ typeParamsForBuilder = getTypeParamExpressions(superclassTypeParams, maker, source.getContext());
// 2. Add the builder type params <C, B>.
typeParamsForBuilder.add(maker.Ident(tdParent.toName(classGenericName)));
typeParamsForBuilder.add(maker.Ident(tdParent.toName(builderGenericName)));
@@ -453,7 +454,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
// 2. The return type for all setter methods (named "B" in the abstract builder), which is this builder class.
JCExpression builderImplClassExpression = namePlusTypeParamsToTypeReference(maker, tdParent, tdParent.toName(builderImplClass), false, typeParams);
- ListBuffer<JCExpression> typeParamsForBuilder = getTypeParamExpressions(typeParams, maker);
+ ListBuffer<JCExpression> typeParamsForBuilder = getTypeParamExpressions(typeParams, maker, source.getContext());
typeParamsForBuilder.add(annotatedClass);
typeParamsForBuilder.add(builderImplClassExpression);
extending = maker.TypeApply(extending, typeParamsForBuilder.toList());
@@ -522,7 +523,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
long flags = JavacHandlerUtil.addFinalIfNeeded(Flags.PARAMETER, typeNode.getContext());
Name builderClassname = typeNode.toName(builderClassName);
// First add all generics that are present on the parent type.
- ListBuffer<JCExpression> typeParamsForBuilderParameter = getTypeParamExpressions(typeParams, maker);
+ ListBuffer<JCExpression> typeParamsForBuilderParameter = getTypeParamExpressions(typeParams, maker, typeNode.getContext());
// Now add the <?, ?>.
JCWildcard wildcard = maker.Wildcard(maker.TypeBoundKind(BoundKind.UNBOUND), null);
typeParamsForBuilderParameter.add(wildcard);
@@ -685,7 +686,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
// 2nd parameter: "FoobarBuilder<?, ?> b" (plus generics on the annotated type)
// First add all generics that are present on the parent type.
- ListBuffer<JCExpression> typeParamsForBuilderParameter = getTypeParamExpressions(typeParams, maker);
+ ListBuffer<JCExpression> typeParamsForBuilderParameter = getTypeParamExpressions(typeParams, maker, type.getContext());
// Now add the <?, ?>.
JCWildcard wildcard = maker.Wildcard(maker.TypeBoundKind(BoundKind.UNBOUND), null);
typeParamsForBuilderParameter.add(wildcard);
@@ -1029,7 +1030,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
return null;
}
- private ListBuffer<JCExpression> getTypeParamExpressions(List<? extends JCTree> typeParams, JavacTreeMaker maker) {
+ private ListBuffer<JCExpression> getTypeParamExpressions(List<? extends JCTree> typeParams, JavacTreeMaker maker, Context context) {
ListBuffer<JCExpression> typeParamsForBuilderParameter = new ListBuffer<JCExpression>();
for (JCTree typeParam : typeParams) {
if (typeParam instanceof JCTypeParameter) {
@@ -1038,6 +1039,8 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
typeParamsForBuilderParameter.add(maker.Ident(((JCIdent)typeParam).getName()));
} else if (typeParam instanceof JCFieldAccess) {
typeParamsForBuilderParameter.add(copySelect(maker, (JCFieldAccess) typeParam));
+ } else if (typeParam instanceof JCTypeApply) {
+ typeParamsForBuilderParameter.add(cloneType(maker, (JCTypeApply)typeParam, typeParam, context));
}
}
return typeParamsForBuilderParameter;
diff --git a/test/transform/resource/after-delombok/SuperBuilderNestedGenericTypes.java b/test/transform/resource/after-delombok/SuperBuilderNestedGenericTypes.java
new file mode 100644
index 00000000..ad738c01
--- /dev/null
+++ b/test/transform/resource/after-delombok/SuperBuilderNestedGenericTypes.java
@@ -0,0 +1,41 @@
+public class SuperBuilderNestedGenericTypes {
+ public static abstract class Generic<T extends Generic<?>> {
+ @java.lang.SuppressWarnings("all")
+ public static abstract class GenericBuilder<T extends Generic<?>, C extends SuperBuilderNestedGenericTypes.Generic<T>, B extends SuperBuilderNestedGenericTypes.Generic.GenericBuilder<T, C, B>> {
+ @java.lang.SuppressWarnings("all")
+ protected abstract B self();
+ @java.lang.SuppressWarnings("all")
+ public abstract C build();
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "SuperBuilderNestedGenericTypes.Generic.GenericBuilder()";
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ protected Generic(final SuperBuilderNestedGenericTypes.Generic.GenericBuilder<T, ?, ?> b) {
+ }
+ }
+ public static abstract class NestedGeneric<T extends OtherGeneric<?>> extends Generic<NestedGeneric<? extends OtherGeneric<?>>> {
+ @java.lang.SuppressWarnings("all")
+ public static abstract class NestedGenericBuilder<T extends OtherGeneric<?>, C extends SuperBuilderNestedGenericTypes.NestedGeneric<T>, B extends SuperBuilderNestedGenericTypes.NestedGeneric.NestedGenericBuilder<T, C, B>> extends Generic.GenericBuilder<NestedGeneric<? extends OtherGeneric<?>>, C, B> {
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected abstract B self();
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public abstract C build();
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "SuperBuilderNestedGenericTypes.NestedGeneric.NestedGenericBuilder(super=" + super.toString() + ")";
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ protected NestedGeneric(final SuperBuilderNestedGenericTypes.NestedGeneric.NestedGenericBuilder<T, ?, ?> b) {
+ super(b);
+ }
+ }
+ public interface OtherGeneric<T> {
+ }
+}
diff --git a/test/transform/resource/after-ecj/SuperBuilderNestedGenericTypes.java b/test/transform/resource/after-ecj/SuperBuilderNestedGenericTypes.java
new file mode 100644
index 00000000..e511b276
--- /dev/null
+++ b/test/transform/resource/after-ecj/SuperBuilderNestedGenericTypes.java
@@ -0,0 +1,37 @@
+public class SuperBuilderNestedGenericTypes {
+ public static abstract @lombok.experimental.SuperBuilder class Generic<T extends Generic<?>> {
+ public static abstract @java.lang.SuppressWarnings("all") class GenericBuilder<T extends Generic<?>, C extends SuperBuilderNestedGenericTypes.Generic<T>, B extends SuperBuilderNestedGenericTypes.Generic.GenericBuilder<T, C, B>> {
+ public GenericBuilder() {
+ super();
+ }
+ protected abstract @java.lang.SuppressWarnings("all") B self();
+ public abstract @java.lang.SuppressWarnings("all") C build();
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return "SuperBuilderNestedGenericTypes.Generic.GenericBuilder()";
+ }
+ }
+ protected @java.lang.SuppressWarnings("all") Generic(final SuperBuilderNestedGenericTypes.Generic.GenericBuilder<T, ?, ?> b) {
+ super();
+ }
+ }
+ public static abstract @lombok.experimental.SuperBuilder class NestedGeneric<T extends OtherGeneric<?>> extends Generic<NestedGeneric<? extends OtherGeneric<?>>> {
+ public static abstract @java.lang.SuppressWarnings("all") class NestedGenericBuilder<T extends OtherGeneric<?>, C extends SuperBuilderNestedGenericTypes.NestedGeneric<T>, B extends SuperBuilderNestedGenericTypes.NestedGeneric.NestedGenericBuilder<T, C, B>> extends Generic.GenericBuilder<NestedGeneric<? extends OtherGeneric<?>>, C, B> {
+ public NestedGenericBuilder() {
+ super();
+ }
+ protected abstract @java.lang.Override @java.lang.SuppressWarnings("all") B self();
+ public abstract @java.lang.Override @java.lang.SuppressWarnings("all") C build();
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (("SuperBuilderNestedGenericTypes.NestedGeneric.NestedGenericBuilder(super=" + super.toString()) + ")");
+ }
+ }
+ protected @java.lang.SuppressWarnings("all") NestedGeneric(final SuperBuilderNestedGenericTypes.NestedGeneric.NestedGenericBuilder<T, ?, ?> b) {
+ super(b);
+ }
+ }
+ public interface OtherGeneric<T> {
+ }
+ public SuperBuilderNestedGenericTypes() {
+ super();
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/before/SuperBuilderNestedGenericTypes.java b/test/transform/resource/before/SuperBuilderNestedGenericTypes.java
new file mode 100644
index 00000000..c463357e
--- /dev/null
+++ b/test/transform/resource/before/SuperBuilderNestedGenericTypes.java
@@ -0,0 +1,12 @@
+public class SuperBuilderNestedGenericTypes {
+ @lombok.experimental.SuperBuilder
+ public static abstract class Generic<T extends Generic<?>> {
+ }
+
+ @lombok.experimental.SuperBuilder
+ public static abstract class NestedGeneric<T extends OtherGeneric<?>> extends Generic<NestedGeneric<? extends OtherGeneric<?>>> {
+ }
+
+ public interface OtherGeneric<T> {
+ }
+}