From 4a34ed75b49f259823739df5691f1d81f37c12ca Mon Sep 17 00:00:00 2001 From: Jan Rieke Date: Fri, 13 Dec 2019 23:32:16 +0100 Subject: avoid more name clashes for builder type param; fixes #2297 --- .../after-delombok/SuperBuilderNameClashes.java | 126 +++++++++++++++++++++ .../after-ecj/SuperBuilderNameClashes.java | 104 +++++++++++++++++ .../resource/before/SuperBuilderNameClashes.java | 17 +++ .../SuperBuilderNameClashes.java.messages | 3 + 4 files changed, 250 insertions(+) create mode 100644 test/transform/resource/after-delombok/SuperBuilderNameClashes.java create mode 100644 test/transform/resource/after-ecj/SuperBuilderNameClashes.java create mode 100644 test/transform/resource/before/SuperBuilderNameClashes.java create mode 100644 test/transform/resource/messages-ecj/SuperBuilderNameClashes.java.messages (limited to 'test/transform') diff --git a/test/transform/resource/after-delombok/SuperBuilderNameClashes.java b/test/transform/resource/after-delombok/SuperBuilderNameClashes.java new file mode 100644 index 00000000..a33fd6b4 --- /dev/null +++ b/test/transform/resource/after-delombok/SuperBuilderNameClashes.java @@ -0,0 +1,126 @@ +public class SuperBuilderNameClashes { + public static class GenericsClash { + @java.lang.SuppressWarnings("all") + public static abstract class GenericsClashBuilder, B2 extends GenericsClashBuilder> { + @java.lang.SuppressWarnings("all") + protected abstract B2 self(); + @java.lang.SuppressWarnings("all") + public abstract C3 build(); + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "SuperBuilderNameClashes.GenericsClash.GenericsClashBuilder()"; + } + } + @java.lang.SuppressWarnings("all") + private static final class GenericsClashBuilderImpl extends GenericsClashBuilder, GenericsClashBuilderImpl> { + @java.lang.SuppressWarnings("all") + private GenericsClashBuilderImpl() { + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + protected GenericsClashBuilderImpl self() { + return this; + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public GenericsClash build() { + return new GenericsClash(this); + } + } + @java.lang.SuppressWarnings("all") + protected GenericsClash(final GenericsClashBuilder b) { + } + @java.lang.SuppressWarnings("all") + public static GenericsClashBuilder builder() { + return new GenericsClashBuilderImpl(); + } + } + public static class B { + @java.lang.SuppressWarnings("all") + public static abstract class BBuilder> { + @java.lang.SuppressWarnings("all") + protected abstract B2 self(); + @java.lang.SuppressWarnings("all") + public abstract C build(); + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "SuperBuilderNameClashes.B.BBuilder()"; + } + } + @java.lang.SuppressWarnings("all") + private static final class BBuilderImpl extends BBuilder { + @java.lang.SuppressWarnings("all") + private BBuilderImpl() { + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + protected BBuilderImpl self() { + return this; + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public B build() { + return new B(this); + } + } + @java.lang.SuppressWarnings("all") + protected B(final BBuilder b) { + } + @java.lang.SuppressWarnings("all") + public static BBuilder builder() { + return new BBuilderImpl(); + } + } + public static class C2 { + } + public static class C { + C2 c2; + @java.lang.SuppressWarnings("all") + public static abstract class CBuilder> { + @java.lang.SuppressWarnings("all") + private C2 c2; + @java.lang.SuppressWarnings("all") + protected abstract B self(); + @java.lang.SuppressWarnings("all") + public abstract C3 build(); + @java.lang.SuppressWarnings("all") + public B c2(final C2 c2) { + this.c2 = c2; + return self(); + } + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "SuperBuilderNameClashes.C.CBuilder(c2=" + this.c2 + ")"; + } + } + @java.lang.SuppressWarnings("all") + private static final class CBuilderImpl extends CBuilder { + @java.lang.SuppressWarnings("all") + private CBuilderImpl() { + } + + @java.lang.Override + @java.lang.SuppressWarnings("all") + protected CBuilderImpl self() { + return this; + } + + @java.lang.Override + @java.lang.SuppressWarnings("all") + public C build() { + return new C(this); + } + } + @java.lang.SuppressWarnings("all") + protected C(final CBuilder b) { + this.c2 = b.c2; + } + @java.lang.SuppressWarnings("all") + public static CBuilder builder() { + return new CBuilderImpl(); + } + } +} diff --git a/test/transform/resource/after-ecj/SuperBuilderNameClashes.java b/test/transform/resource/after-ecj/SuperBuilderNameClashes.java new file mode 100644 index 00000000..dd238b5d --- /dev/null +++ b/test/transform/resource/after-ecj/SuperBuilderNameClashes.java @@ -0,0 +1,104 @@ +public class SuperBuilderNameClashes { + public static @lombok.experimental.SuperBuilder class GenericsClash { + public static abstract @java.lang.SuppressWarnings("all") class GenericsClashBuilder, B2 extends GenericsClashBuilder> { + public GenericsClashBuilder() { + super(); + } + protected abstract @java.lang.SuppressWarnings("all") B2 self(); + public abstract @java.lang.SuppressWarnings("all") C3 build(); + public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { + return "SuperBuilderNameClashes.GenericsClash.GenericsClashBuilder()"; + } + } + private static final @java.lang.SuppressWarnings("all") class GenericsClashBuilderImpl extends GenericsClashBuilder, GenericsClashBuilderImpl> { + private GenericsClashBuilderImpl() { + super(); + } + protected @java.lang.Override @java.lang.SuppressWarnings("all") GenericsClashBuilderImpl self() { + return this; + } + public @java.lang.Override @java.lang.SuppressWarnings("all") GenericsClash build() { + return new GenericsClash(this); + } + } + protected @java.lang.SuppressWarnings("all") GenericsClash(final GenericsClashBuilder b) { + super(); + } + public static @java.lang.SuppressWarnings("all") GenericsClashBuilder builder() { + return new GenericsClashBuilderImpl(); + } + } + public static @lombok.experimental.SuperBuilder class B { + public static abstract @java.lang.SuppressWarnings("all") class BBuilder> { + public BBuilder() { + super(); + } + protected abstract @java.lang.SuppressWarnings("all") B2 self(); + public abstract @java.lang.SuppressWarnings("all") C build(); + public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { + return "SuperBuilderNameClashes.B.BBuilder()"; + } + } + private static final @java.lang.SuppressWarnings("all") class BBuilderImpl extends BBuilder { + private BBuilderImpl() { + super(); + } + protected @java.lang.Override @java.lang.SuppressWarnings("all") BBuilderImpl self() { + return this; + } + public @java.lang.Override @java.lang.SuppressWarnings("all") B build() { + return new B(this); + } + } + protected @java.lang.SuppressWarnings("all") B(final BBuilder b) { + super(); + } + public static @java.lang.SuppressWarnings("all") BBuilder builder() { + return new BBuilderImpl(); + } + } + public static class C2 { + public C2() { + super(); + } + } + public static @lombok.experimental.SuperBuilder class C { + public static abstract @java.lang.SuppressWarnings("all") class CBuilder> { + private @java.lang.SuppressWarnings("all") C2 c2; + public CBuilder() { + super(); + } + protected abstract @java.lang.SuppressWarnings("all") B self(); + public abstract @java.lang.SuppressWarnings("all") C3 build(); + public @java.lang.SuppressWarnings("all") B c2(final C2 c2) { + this.c2 = c2; + return self(); + } + public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { + return (("SuperBuilderNameClashes.C.CBuilder(c2=" + this.c2) + ")"); + } + } + private static final @java.lang.SuppressWarnings("all") class CBuilderImpl extends CBuilder { + private CBuilderImpl() { + super(); + } + protected @java.lang.Override @java.lang.SuppressWarnings("all") CBuilderImpl self() { + return this; + } + public @java.lang.Override @java.lang.SuppressWarnings("all") C build() { + return new C(this); + } + } + C2 c2; + protected @java.lang.SuppressWarnings("all") C(final CBuilder b) { + super(); + this.c2 = b.c2; + } + public static @java.lang.SuppressWarnings("all") CBuilder builder() { + return new CBuilderImpl(); + } + } + public SuperBuilderNameClashes() { + super(); + } +} \ No newline at end of file diff --git a/test/transform/resource/before/SuperBuilderNameClashes.java b/test/transform/resource/before/SuperBuilderNameClashes.java new file mode 100644 index 00000000..a0b58452 --- /dev/null +++ b/test/transform/resource/before/SuperBuilderNameClashes.java @@ -0,0 +1,17 @@ +public class SuperBuilderNameClashes { + @lombok.experimental.SuperBuilder + public static class GenericsClash { + } + + @lombok.experimental.SuperBuilder + public static class B { + } + + public static class C2 { + } + + @lombok.experimental.SuperBuilder + public static class C { + C2 c2; + } +} diff --git a/test/transform/resource/messages-ecj/SuperBuilderNameClashes.java.messages b/test/transform/resource/messages-ecj/SuperBuilderNameClashes.java.messages new file mode 100644 index 00000000..59774b92 --- /dev/null +++ b/test/transform/resource/messages-ecj/SuperBuilderNameClashes.java.messages @@ -0,0 +1,3 @@ +3 WARNING The type parameter B is hiding the type SuperBuilderNameClashes.B +3 WARNING The type parameter C is hiding the type SuperBuilderNameClashes.C +3 WARNING The type parameter C2 is hiding the type SuperBuilderNameClashes.C2 \ No newline at end of file -- cgit