aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRawi01 <Rawi01@users.noreply.github.com>2020-05-09 13:19:17 +0200
committerRoel Spilker <r.spilker@gmail.com>2020-05-28 21:22:53 +0200
commit7d08af7d856b41580fa4b913e2b0c9002a8fc341 (patch)
tree767586c7345da23f1aa034f97477c74932609793
parent77ab1cf867359a2999e3d3962060acddd5565d14 (diff)
downloadlombok-7d08af7d856b41580fa4b913e2b0c9002a8fc341.tar.gz
lombok-7d08af7d856b41580fa4b913e2b0c9002a8fc341.tar.bz2
lombok-7d08af7d856b41580fa4b913e2b0c9002a8fc341.zip
[fixes #2382] Handle generic supertypes
-rw-r--r--src/core/lombok/javac/handlers/HandleDelegate.java9
-rw-r--r--test/transform/resource/after-delombok/DelegateGenerics.java32
-rw-r--r--test/transform/resource/after-ecj/DelegateGenerics.java24
-rw-r--r--test/transform/resource/before/DelegateGenerics.java14
4 files changed, 75 insertions, 4 deletions
diff --git a/src/core/lombok/javac/handlers/HandleDelegate.java b/src/core/lombok/javac/handlers/HandleDelegate.java
index 367b2cff..c19540fa 100644
--- a/src/core/lombok/javac/handlers/HandleDelegate.java
+++ b/src/core/lombok/javac/handlers/HandleDelegate.java
@@ -389,10 +389,11 @@ public class HandleDelegate extends JavacAnnotationHandler<Delegate> {
boolean isDeprecated = (member.flags() & DEPRECATED) != 0;
signatures.add(new MethodSig(member.name, methodType, isDeprecated, exElem));
}
-
- if (ct.supertype_field instanceof ClassType) addMethodBindings(signatures, (ClassType) ct.supertype_field, types, banList);
- if (ct.interfaces_field != null) for (Type iface : ct.interfaces_field) {
- if (iface instanceof ClassType) addMethodBindings(signatures, (ClassType) iface, types, banList);
+
+ for (Type type : types.directSupertypes(ct)) {
+ if (type instanceof ClassType) {
+ addMethodBindings(signatures, (ClassType) type, types, banList);
+ }
}
}
diff --git a/test/transform/resource/after-delombok/DelegateGenerics.java b/test/transform/resource/after-delombok/DelegateGenerics.java
new file mode 100644
index 00000000..894776ea
--- /dev/null
+++ b/test/transform/resource/after-delombok/DelegateGenerics.java
@@ -0,0 +1,32 @@
+public class DelegateGenerics<T> {
+ I1<T> target;
+
+ @java.lang.SuppressWarnings("all")
+ public java.lang.Integer t(final java.lang.Integer t) {
+ return this.target.t(t);
+ }
+
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String i(final java.lang.String a) {
+ return this.target.i(a);
+ }
+
+ @java.lang.SuppressWarnings("all")
+ public T a(final T a) {
+ return this.target.a(a);
+ }
+}
+
+interface I1<T> extends I2<T, Integer, String> {
+}
+
+interface I2<A, T, I> extends I3<Integer, I, A> {
+}
+
+interface I3<T, I, A> {
+ T t(T t);
+
+ I i(I a);
+
+ A a(A a);
+} \ No newline at end of file
diff --git a/test/transform/resource/after-ecj/DelegateGenerics.java b/test/transform/resource/after-ecj/DelegateGenerics.java
new file mode 100644
index 00000000..97b05102
--- /dev/null
+++ b/test/transform/resource/after-ecj/DelegateGenerics.java
@@ -0,0 +1,24 @@
+public class DelegateGenerics<T> {
+ @lombok.experimental.Delegate I1<T> target;
+ public DelegateGenerics() {
+ super();
+ }
+ public @java.lang.SuppressWarnings("all") T a(final T a) {
+ return this.target.a(a);
+ }
+ public @java.lang.SuppressWarnings("all") java.lang.String i(final java.lang.String a) {
+ return this.target.i(a);
+ }
+ public @java.lang.SuppressWarnings("all") java.lang.Integer t(final java.lang.Integer t) {
+ return this.target.t(t);
+ }
+}
+interface I1<T> extends I2<T, Integer, String> {
+}
+interface I2<A, T, I> extends I3<Integer, I, A> {
+}
+interface I3<T, I, A> {
+ public T t(T t);
+ public I i(I a);
+ public A a(A a);
+} \ No newline at end of file
diff --git a/test/transform/resource/before/DelegateGenerics.java b/test/transform/resource/before/DelegateGenerics.java
new file mode 100644
index 00000000..e89158a9
--- /dev/null
+++ b/test/transform/resource/before/DelegateGenerics.java
@@ -0,0 +1,14 @@
+public class DelegateGenerics<T> {
+ @lombok.experimental.Delegate
+ I1<T> target;
+}
+
+interface I1<T> extends I2<T, Integer, String> {
+}
+interface I2<A, T, I> extends I3<Integer, I, A> {
+}
+interface I3<T, I, A> {
+ public T t(T t);
+ public I i(I a);
+ public A a(A a);
+} \ No newline at end of file