diff options
author | peichhorn <peichhor@web.de> | 2011-05-30 21:17:46 +0200 |
---|---|---|
committer | peichhorn <peichhor@web.de> | 2011-05-30 21:26:45 +0200 |
commit | daf84dd00ed5059710acf9f40b4663ba7fed06e0 (patch) | |
tree | 3e4bdcebd2f78aab9a5305160d60e9846e74241e | |
parent | 1e7c6b98caec18a1f3747a7e0303df88b42ffac2 (diff) | |
download | lombok-daf84dd00ed5059710acf9f40b4663ba7fed06e0.tar.gz lombok-daf84dd00ed5059710acf9f40b4663ba7fed06e0.tar.bz2 lombok-daf84dd00ed5059710acf9f40b4663ba7fed06e0.zip |
HandleDelegate did not remove the annotation @Delegate from javac's AST, so HandleDelegate was called multiple times for the same field resulting in an error saying the delegate method was already defined.
Also added a test for @Delegate that uncovered this issue.
4 files changed, 67 insertions, 0 deletions
diff --git a/src/core/lombok/javac/handlers/HandleDelegate.java b/src/core/lombok/javac/handlers/HandleDelegate.java index 071aa3e4..e333daa3 100644 --- a/src/core/lombok/javac/handlers/HandleDelegate.java +++ b/src/core/lombok/javac/handlers/HandleDelegate.java @@ -21,6 +21,8 @@ */ package lombok.javac.handlers; +import static lombok.javac.handlers.JavacHandlerUtil.markAnnotationAsProcessed; + import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -90,6 +92,7 @@ public class HandleDelegate implements JavacAnnotationHandler<Delegate> { "finalize()")); @Override public boolean handle(AnnotationValues<Delegate> annotation, JCAnnotation ast, JavacNode annotationNode) { + markAnnotationAsProcessed(annotationNode, Delegate.class); if (annotationNode.up().getKind() != Kind.FIELD) { // As the annotation is legal on fields only, javac itself will take care of printing an error message for this. return false; diff --git a/test/transform/resource/after-delombok/DelegateTypesAndExcludes.java b/test/transform/resource/after-delombok/DelegateTypesAndExcludes.java new file mode 100644 index 00000000..3f6f555d --- /dev/null +++ b/test/transform/resource/after-delombok/DelegateTypesAndExcludes.java @@ -0,0 +1,35 @@ +class DelegatePlain { + private final BarImpl bar = new BarImpl(); + private final FooImpl foo = new FooImpl(); + + private static class FooImpl implements Foo { + public void foo() { + } + + public void bar(java.util.ArrayList<java.lang.String> list) { + } + } + + private static class BarImpl implements Bar { + public void bar(java.util.ArrayList<java.lang.String> list) { + } + } + + private static interface Foo extends Bar { + void foo(); + } + + private static interface Bar { + void bar(java.util.ArrayList<java.lang.String> list); + } + + @java.lang.SuppressWarnings("all") + public void bar(final java.util.ArrayList<java.lang.String> list) { + this.bar.bar(list); + } + + @java.lang.SuppressWarnings("all") + public void foo() { + this.foo.foo(); + } +}
\ No newline at end of file diff --git a/test/transform/resource/after-ecj/DelegateTypesAndExcludes.java b/test/transform/resource/after-ecj/DelegateTypesAndExcludes.java new file mode 100644 index 00000000..cb06d3c1 --- /dev/null +++ b/test/transform/resource/after-ecj/DelegateTypesAndExcludes.java @@ -0,0 +1 @@ +//ignore
\ No newline at end of file diff --git a/test/transform/resource/before/DelegateTypesAndExcludes.java b/test/transform/resource/before/DelegateTypesAndExcludes.java new file mode 100644 index 00000000..da7fc4cb --- /dev/null +++ b/test/transform/resource/before/DelegateTypesAndExcludes.java @@ -0,0 +1,28 @@ +import lombok.Delegate; +class DelegatePlain { + @Delegate(types = Bar.class) + private final BarImpl bar = new BarImpl(); + @Delegate(types = Foo.class, excludes = Bar.class) + private final FooImpl foo = new FooImpl(); + + private static class FooImpl implements Foo { + public void foo() { + } + + public void bar(java.util.ArrayList<java.lang.String> list) { + } + } + + private static class BarImpl implements Bar { + public void bar(java.util.ArrayList<java.lang.String> list) { + } + } + + private static interface Foo extends Bar { + void foo(); + } + + private static interface Bar { + void bar(java.util.ArrayList<java.lang.String> list); + } +}
\ No newline at end of file |