mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-15 00:17:45 +00:00
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.
This commit is contained in:
1 parent
1e7c6b98ca
commit
daf84dd00e
4 files changed
+67
No files matched your search
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
//ignore
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user