aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2019-12-19 03:19:24 +0100
committerGitHub <noreply@github.com>2019-12-19 03:19:24 +0100
commit859c1149727a98648ab9ad2763f26f351448851f (patch)
tree32ee4b7f1ca798642aebad359e6a40fbdd539f87
parent1b0055893822a7edc135e5c7bdcbbd63584dec2a (diff)
parent31086f05ac06f19da2b5b3aba364e8bdad40a85a (diff)
downloadlombok-859c1149727a98648ab9ad2763f26f351448851f.tar.gz
lombok-859c1149727a98648ab9ad2763f26f351448851f.tar.bz2
lombok-859c1149727a98648ab9ad2763f26f351448851f.zip
Merge pull request #2273 from Lekanich/issue2262
Fixed @SuperBuilder with generic with inner static class produces CE
-rwxr-xr-xAUTHORS1
-rw-r--r--src/core/lombok/javac/handlers/HandleSuperBuilder.java28
2 files changed, 29 insertions, 0 deletions
diff --git a/AUTHORS b/AUTHORS
index 77cbbfe9..fa0f5e1e 100755
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,6 +1,7 @@
Lombok contributors in alphabetical order:
Adam Juraszek <juriad@gmail.com>
+Aleksandr Zhelezniak <lekan1992@gmail.com>
Bulgakov Alexander <buls@yandex.ru>
Caleb Brinkman <floralvikings@gmail.com>
Christian Nüssgens <christian@nuessgens.com>
diff --git a/src/core/lombok/javac/handlers/HandleSuperBuilder.java b/src/core/lombok/javac/handlers/HandleSuperBuilder.java
index 0f809571..83dc23d1 100644
--- a/src/core/lombok/javac/handlers/HandleSuperBuilder.java
+++ b/src/core/lombok/javac/handlers/HandleSuperBuilder.java
@@ -26,6 +26,7 @@ import static lombok.javac.Javac.*;
import static lombok.javac.handlers.JavacHandlerUtil.*;
import java.util.ArrayList;
+import java.util.Collections;
import javax.lang.model.element.Modifier;
@@ -1007,8 +1008,35 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
typeParamsForBuilderParameter.add(maker.Ident(((JCTypeParameter)typeParam).getName()));
} else if (typeParam instanceof JCIdent) {
typeParamsForBuilderParameter.add(maker.Ident(((JCIdent)typeParam).getName()));
+ } else if (typeParam instanceof JCFieldAccess) {
+ typeParamsForBuilderParameter.add(copySelect(maker, (JCFieldAccess) typeParam));
}
}
return typeParamsForBuilderParameter;
}
+
+ private JCExpression copySelect(JavacTreeMaker maker, JCFieldAccess typeParam) {
+ java.util.List<Name> chainNames = new ArrayList<Name>();
+ JCExpression expression = typeParam;
+ while (expression != null) {
+ if (expression instanceof JCFieldAccess) {
+ chainNames.add(((JCFieldAccess) expression).getIdentifier());
+ expression = ((JCFieldAccess) expression).getExpression();
+ } else if (expression instanceof JCIdent) {
+ chainNames.add(((JCIdent) expression).getName());
+ expression = null;
+ }
+ }
+
+ Collections.reverse(chainNames);
+ JCExpression typeParameter = null;
+ for (Name name : chainNames) {
+ if (typeParameter == null) {
+ typeParameter = maker.Ident(name);
+ } else {
+ typeParameter = maker.Select(typeParameter, name);
+ }
+ }
+ return typeParameter;
+ }
}