aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/changelog.markdown3
-rw-r--r--src/core/lombok/javac/handlers/HandleDelegate.java8
-rw-r--r--test/transform/resource/after-delombok/DelegateWithVarargs.java29
-rw-r--r--test/transform/resource/after-ecj/DelegateWithVarargs.java25
-rw-r--r--test/transform/resource/before/DelegateWithVarargs.java12
5 files changed, 74 insertions, 3 deletions
diff --git a/doc/changelog.markdown b/doc/changelog.markdown
index 3c7e31c5..74d2fdc8 100644
--- a/doc/changelog.markdown
+++ b/doc/changelog.markdown
@@ -15,8 +15,9 @@ Lombok Changelog
* FEATURE: A `lombok.config` key can now be used to set the default behaviour of `@EqualsAndHashCode` when generating methods for a class that extends something in regards to calling the superclass implementations of `equals` and `hashCode` or not. [Issue #965](https://github.com/rzwitserloot/lombok/issues/965).
* FEATURE: Putting `@Wither` on abstract classes now generates something slightly more useful: An abstract wither method. [Issue #945](https://github.com/rzwitserloot/lombok/issues/945).
* BUGFIX: lambdas with 1 argument that has an explicit type did not pretty print correctly. [Issue #972](https://github.com/rzwitserloot/lombok/issues/972).
-* BUGFIX: `@Value` and `@FieldDefaults` no longer make uninitialized static fields final. [Issue #928](https://github.com/rzwitserloot/lombok/issues/928).
* BUGFIX: When using delombok, a source file with only `@NonNull` annotations on parameters as lombok feature would not get properly delomboked. [Issue #950](https://github.com/rzwitserloot/lombok/issues/950).
+* BUGFIX: `@Delegate` in javac would generate arrays instead of varargs parameters. [Issue #932](https://github.com/rzwitserloot/lombok/issues/932).
+* BUGFIX: `@Value` and `@FieldDefaults` no longer make uninitialized static fields final. [Issue #928](https://github.com/rzwitserloot/lombok/issues/928).
* ENHANCEMENT: Putting `@NonNull` on a parameter of an abstract method no longer generates a warning, to allow you to use this annotation to document intended behaviour [Issue #807](https://github.com/rzwitserloot/lombok/issues/807).
### v1.16.6 (August 18th, 2015)
diff --git a/src/core/lombok/javac/handlers/HandleDelegate.java b/src/core/lombok/javac/handlers/HandleDelegate.java
index fc3c81f3..680e7745 100644
--- a/src/core/lombok/javac/handlers/HandleDelegate.java
+++ b/src/core/lombok/javac/handlers/HandleDelegate.java
@@ -299,7 +299,7 @@ public class HandleDelegate extends JavacAnnotationHandler<Delegate> {
annotations = com.sun.tools.javac.util.List.nil();
}
- JCModifiers mods = maker.Modifiers(Flags.PUBLIC, annotations);
+ JCModifiers mods = maker.Modifiers(PUBLIC, annotations);
JCExpression returnType = JavacResolution.typeToJCTree((Type) sig.type.getReturnType(), annotation.getAst(), true);
boolean useReturn = sig.type.getReturnType().getKind() != TypeKind.VOID;
ListBuffer<JCVariableDecl> params = sig.type.getParameterTypes().isEmpty() ? null : new ListBuffer<JCVariableDecl>();
@@ -326,11 +326,15 @@ public class HandleDelegate extends JavacAnnotationHandler<Delegate> {
}
int idx = 0;
+ String[] paramNames = sig.getParameterNames();
+ boolean varargs = sig.elem.isVarArgs();
for (TypeMirror param : sig.type.getParameterTypes()) {
long flags = JavacHandlerUtil.addFinalIfNeeded(Flags.PARAMETER, annotation.getContext());
JCModifiers paramMods = maker.Modifiers(flags);
- String[] paramNames = sig.getParameterNames();
Name name = annotation.toName(paramNames[idx++]);
+ if (varargs && idx == paramNames.length) {
+ paramMods.flags |= VARARGS;
+ }
params.append(maker.VarDef(paramMods, name, JavacResolution.typeToJCTree((Type) param, annotation.getAst(), true), null));
args.append(maker.Ident(name));
}
diff --git a/test/transform/resource/after-delombok/DelegateWithVarargs.java b/test/transform/resource/after-delombok/DelegateWithVarargs.java
new file mode 100644
index 00000000..1d240524
--- /dev/null
+++ b/test/transform/resource/after-delombok/DelegateWithVarargs.java
@@ -0,0 +1,29 @@
+class DelegateWithVarargs {
+ private Bar bar;
+ private interface Bar {
+ void justOneParameter(int... varargs);
+ void multipleParameters(String first, int... varargs);
+ void array(int[] array);
+ void arrayVarargs(int[]... arrayVarargs);
+ }
+ @java.lang.SuppressWarnings("all")
+ @javax.annotation.Generated("lombok")
+ public void justOneParameter(final int... varargs) {
+ this.bar.justOneParameter(varargs);
+ }
+ @java.lang.SuppressWarnings("all")
+ @javax.annotation.Generated("lombok")
+ public void multipleParameters(final java.lang.String first, final int... varargs) {
+ this.bar.multipleParameters(first, varargs);
+ }
+ @java.lang.SuppressWarnings("all")
+ @javax.annotation.Generated("lombok")
+ public void array(final int[] array) {
+ this.bar.array(array);
+ }
+ @java.lang.SuppressWarnings("all")
+ @javax.annotation.Generated("lombok")
+ public void arrayVarargs(final int[]... arrayVarargs) {
+ this.bar.arrayVarargs(arrayVarargs);
+ }
+}
diff --git a/test/transform/resource/after-ecj/DelegateWithVarargs.java b/test/transform/resource/after-ecj/DelegateWithVarargs.java
new file mode 100644
index 00000000..a0b5b7b5
--- /dev/null
+++ b/test/transform/resource/after-ecj/DelegateWithVarargs.java
@@ -0,0 +1,25 @@
+import lombok.experimental.Delegate;
+class DelegateWithVarargs {
+ private interface Bar {
+ void justOneParameter(int... varargs);
+ void multipleParameters(String first, int... varargs);
+ void array(int[] array);
+ void arrayVarargs(int[]... arrayVarargs);
+ }
+ private @Delegate Bar bar;
+ DelegateWithVarargs() {
+ super();
+ }
+ public @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") void array(final int[] array) {
+ this.bar.array(array);
+ }
+ public @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") void arrayVarargs(final int[]... arrayVarargs) {
+ this.bar.arrayVarargs(arrayVarargs);
+ }
+ public @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") void justOneParameter(final int... varargs) {
+ this.bar.justOneParameter(varargs);
+ }
+ public @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") void multipleParameters(final java.lang.String first, final int... varargs) {
+ this.bar.multipleParameters(first, varargs);
+ }
+}
diff --git a/test/transform/resource/before/DelegateWithVarargs.java b/test/transform/resource/before/DelegateWithVarargs.java
new file mode 100644
index 00000000..0c266620
--- /dev/null
+++ b/test/transform/resource/before/DelegateWithVarargs.java
@@ -0,0 +1,12 @@
+import lombok.experimental.Delegate;
+
+class DelegateWithVarargs {
+ @Delegate private Bar bar;
+
+ private interface Bar {
+ void justOneParameter(int... varargs);
+ void multipleParameters(String first, int... varargs);
+ void array(int[] array);
+ void arrayVarargs(int[]... arrayVarargs);
+ }
+} \ No newline at end of file