From 4fdcdd126a4b5ce365b97eb498536d04caee3b53 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Fri, 10 Jul 2020 02:51:00 +0200 Subject: [test] this covers more eclipse versions --- .../CheckerFrameworkSuperBuilder.java | 30 ++++++------ .../resource/after-delombok/ValLambda.java | 6 ++- .../after-ecj/CheckerFrameworkSuperBuilder.java | 32 ++++++------- .../after-ecj/EqualsAndHashCodeAnnotated.java | 53 ++++++++++++++++++++++ test/transform/resource/after-ecj/ValLambda.java | 6 ++- .../before/CheckerFrameworkSuperBuilder.java | 2 +- test/transform/resource/before/ValLambda.java | 6 ++- test/transform/resource/before/ValLub.java | 10 ++-- .../resource/messages-ecj/ValLambda.java.messages | 4 +- 9 files changed, 104 insertions(+), 45 deletions(-) create mode 100644 test/transform/resource/after-ecj/EqualsAndHashCodeAnnotated.java diff --git a/test/transform/resource/after-delombok/CheckerFrameworkSuperBuilder.java b/test/transform/resource/after-delombok/CheckerFrameworkSuperBuilder.java index 0f7f8997..e0daad32 100644 --- a/test/transform/resource/after-delombok/CheckerFrameworkSuperBuilder.java +++ b/test/transform/resource/after-delombok/CheckerFrameworkSuperBuilder.java @@ -124,7 +124,7 @@ class CheckerFrameworkSuperBuilder { return new CheckerFrameworkSuperBuilder.Parent.ParentBuilderImpl(); } } - public static class Child extends Parent { + public static class ZChild extends Parent { int a; int b; @java.lang.SuppressWarnings("all") @@ -132,7 +132,7 @@ class CheckerFrameworkSuperBuilder { return 1; } @java.lang.SuppressWarnings("all") - public static abstract class ChildBuilder> extends Parent.ParentBuilder { + public static abstract class ChildBuilder> extends Parent.ParentBuilder { @java.lang.SuppressWarnings("all") private boolean a$set; @java.lang.SuppressWarnings("all") @@ -147,17 +147,17 @@ class CheckerFrameworkSuperBuilder { @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.Override @java.lang.SuppressWarnings("all") - public abstract C build(@org.checkerframework.checker.builder.qual.CalledMethods("b") CheckerFrameworkSuperBuilder.Child this); + public abstract C build(@org.checkerframework.checker.builder.qual.CalledMethods("b") CheckerFrameworkSuperBuilder.ZChild this); @org.checkerframework.checker.builder.qual.ReturnsReceiver @java.lang.SuppressWarnings("all") - public B a(@org.checkerframework.checker.builder.qual.NotCalledMethods("a") CheckerFrameworkSuperBuilder.Child.ChildBuilder this, final int a) { + public B a(@org.checkerframework.checker.builder.qual.NotCalledMethods("a") CheckerFrameworkSuperBuilder.ZChild.ZChildBuilder this, final int a) { this.a$value = a; a$set = true; return self(); } @org.checkerframework.checker.builder.qual.ReturnsReceiver @java.lang.SuppressWarnings("all") - public B b(@org.checkerframework.checker.builder.qual.NotCalledMethods("b") CheckerFrameworkSuperBuilder.Child.ChildBuilder this, final int b) { + public B b(@org.checkerframework.checker.builder.qual.NotCalledMethods("b") CheckerFrameworkSuperBuilder.ZChild.ZChildBuilder this, final int b) { this.b = b; return self(); } @@ -165,41 +165,41 @@ class CheckerFrameworkSuperBuilder { @java.lang.Override @java.lang.SuppressWarnings("all") public java.lang.String toString() { - return "CheckerFrameworkSuperBuilder.Child.ChildBuilder(super=" + super.toString() + ", a$value=" + this.a$value + ", b=" + this.b + ")"; + return "CheckerFrameworkSuperBuilder.ZChild.ZChildBuilder(super=" + super.toString() + ", a$value=" + this.a$value + ", b=" + this.b + ")"; } } @java.lang.SuppressWarnings("all") - private static final class ChildBuilderImpl extends CheckerFrameworkSuperBuilder.Child.ChildBuilder { + private static final class ZChildBuilderImpl extends CheckerFrameworkSuperBuilder.ZChild.ZChildBuilder { @org.checkerframework.common.aliasing.qual.Unique @java.lang.SuppressWarnings("all") - private ChildBuilderImpl() { + private ZChildBuilderImpl() { } @java.lang.Override @org.checkerframework.checker.builder.qual.ReturnsReceiver @org.checkerframework.dataflow.qual.Pure @java.lang.SuppressWarnings("all") - protected CheckerFrameworkSuperBuilder.Child.ChildBuilderImpl self() { + protected CheckerFrameworkSuperBuilder.ZChild.ZChildBuilderImpl self() { return this; } @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.Override @java.lang.SuppressWarnings("all") - public CheckerFrameworkSuperBuilder.Child build(@org.checkerframework.checker.builder.qual.CalledMethods("b") CheckerFrameworkSuperBuilder.Child.ChildBuilderImpl this) { - return new CheckerFrameworkSuperBuilder.Child(this); + public CheckerFrameworkSuperBuilder.ZChild build(@org.checkerframework.checker.builder.qual.CalledMethods("b") CheckerFrameworkSuperBuilder.ZChild.ZChildBuilderImpl this) { + return new CheckerFrameworkSuperBuilder.ZChild(this); } } @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.SuppressWarnings("all") - protected Child(final CheckerFrameworkSuperBuilder.Child.ChildBuilder b) { + protected ZChild(final CheckerFrameworkSuperBuilder.ZChild.ZChildBuilder b) { super(b); if (b.a$set) this.a = b.a$value; - else this.a = CheckerFrameworkSuperBuilder.Child.$default$a(); + else this.a = CheckerFrameworkSuperBuilder.ZChild.$default$a(); this.b = b.b; } @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.SuppressWarnings("all") - public static CheckerFrameworkSuperBuilder.Child.ChildBuilder builder() { - return new CheckerFrameworkSuperBuilder.Child.ChildBuilderImpl(); + public static CheckerFrameworkSuperBuilder.ZChild.ZChildBuilder builder() { + return new CheckerFrameworkSuperBuilder.ZChild.ZChildBuilderImpl(); } } } \ No newline at end of file diff --git a/test/transform/resource/after-delombok/ValLambda.java b/test/transform/resource/after-delombok/ValLambda.java index 24ae3b5f..910e3506 100644 --- a/test/transform/resource/after-delombok/ValLambda.java +++ b/test/transform/resource/after-delombok/ValLambda.java @@ -1,4 +1,6 @@ // version 8: +import java.io.Serializable; + class ValLambda { static { final java.lang.Runnable foo = (System.currentTimeMillis() > 0) ? (Runnable) () -> { @@ -15,8 +17,8 @@ class ValLambda { }; } - public void easyIntersectionLambda() { - final java.lang.Runnable foo = (Runnable & java.io.Serializable) () -> { + public void intersectionLambda() { + final java.io.Serializable foo = (Runnable & Serializable) () -> { }; final java.io.Serializable bar = (java.io.Serializable & Runnable) () -> { }; diff --git a/test/transform/resource/after-ecj/CheckerFrameworkSuperBuilder.java b/test/transform/resource/after-ecj/CheckerFrameworkSuperBuilder.java index 43568236..7c8ff0ed 100644 --- a/test/transform/resource/after-ecj/CheckerFrameworkSuperBuilder.java +++ b/test/transform/resource/after-ecj/CheckerFrameworkSuperBuilder.java @@ -94,38 +94,38 @@ class CheckerFrameworkSuperBuilder { return new CheckerFrameworkSuperBuilder.Parent.ParentBuilderImpl(); } } - public static @lombok.experimental.SuperBuilder class Child extends Parent { - public static abstract @java.lang.SuppressWarnings("all") class ChildBuilder> extends Parent.ParentBuilder { + public static @lombok.experimental.SuperBuilder class ZChild extends Parent { + public static abstract @java.lang.SuppressWarnings("all") class ZChildBuilder> extends Parent.ParentBuilder { private @java.lang.SuppressWarnings("all") int a$value; private @java.lang.SuppressWarnings("all") boolean a$set; private @java.lang.SuppressWarnings("all") int b; - public ChildBuilder() { + public ZChildBuilder() { super(); } protected abstract @java.lang.Override @org.checkerframework.checker.builder.qual.ReturnsReceiver @org.checkerframework.dataflow.qual.Pure @java.lang.SuppressWarnings("all") B self(); - public abstract @java.lang.Override @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.SuppressWarnings("all") C build(final @org.checkerframework.checker.builder.qual.CalledMethods("b") CheckerFrameworkSuperBuilder.Child.ChildBuilder this); - public @org.checkerframework.checker.builder.qual.ReturnsReceiver @java.lang.SuppressWarnings("all") B a(final @org.checkerframework.checker.builder.qual.NotCalledMethods("a") CheckerFrameworkSuperBuilder.Child.ChildBuilder this, final int a) { + public abstract @java.lang.Override @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.SuppressWarnings("all") C build(final @org.checkerframework.checker.builder.qual.CalledMethods("b") CheckerFrameworkSuperBuilder.ZChild.ZChildBuilder this); + public @org.checkerframework.checker.builder.qual.ReturnsReceiver @java.lang.SuppressWarnings("all") B a(final @org.checkerframework.checker.builder.qual.NotCalledMethods("a") CheckerFrameworkSuperBuilder.ZChild.ZChildBuilder this, final int a) { this.a$value = a; a$set = true; return self(); } - public @org.checkerframework.checker.builder.qual.ReturnsReceiver @java.lang.SuppressWarnings("all") B b(final @org.checkerframework.checker.builder.qual.NotCalledMethods("b") CheckerFrameworkSuperBuilder.Child.ChildBuilder this, final int b) { + public @org.checkerframework.checker.builder.qual.ReturnsReceiver @java.lang.SuppressWarnings("all") B b(final @org.checkerframework.checker.builder.qual.NotCalledMethods("b") CheckerFrameworkSuperBuilder.ZChild.ZChildBuilder this, final int b) { this.b = b; return self(); } public @java.lang.Override @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.SuppressWarnings("all") java.lang.String toString() { - return (((((("CheckerFrameworkSuperBuilder.Child.ChildBuilder(super=" + super.toString()) + ", a$value=") + this.a$value) + ", b=") + this.b) + ")"); + return (((((("CheckerFrameworkSuperBuilder.ZChild.ZChildBuilder(super=" + super.toString()) + ", a$value=") + this.a$value) + ", b=") + this.b) + ")"); } } - private static final @java.lang.SuppressWarnings("all") class ChildBuilderImpl extends CheckerFrameworkSuperBuilder.Child.ChildBuilder { - private ChildBuilderImpl() { + private static final @java.lang.SuppressWarnings("all") class ZChildBuilderImpl extends CheckerFrameworkSuperBuilder.ZChild.ZChildBuilder { + private ZChildBuilderImpl() { super(); } - protected @java.lang.Override @org.checkerframework.checker.builder.qual.ReturnsReceiver @org.checkerframework.dataflow.qual.Pure @java.lang.SuppressWarnings("all") CheckerFrameworkSuperBuilder.Child.ChildBuilderImpl self() { + protected @java.lang.Override @org.checkerframework.checker.builder.qual.ReturnsReceiver @org.checkerframework.dataflow.qual.Pure @java.lang.SuppressWarnings("all") CheckerFrameworkSuperBuilder.ZChild.ZChildBuilderImpl self() { return this; } - public @java.lang.Override @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.SuppressWarnings("all") CheckerFrameworkSuperBuilder.Child build(final @org.checkerframework.checker.builder.qual.CalledMethods("b") CheckerFrameworkSuperBuilder.Child.ChildBuilderImpl this) { - return new CheckerFrameworkSuperBuilder.Child(this); + public @java.lang.Override @org.checkerframework.dataflow.qual.SideEffectFree @java.lang.SuppressWarnings("all") CheckerFrameworkSuperBuilder.ZChild build(final @org.checkerframework.checker.builder.qual.CalledMethods("b") CheckerFrameworkSuperBuilder.ZChild.ZChildBuilderImpl this) { + return new CheckerFrameworkSuperBuilder.ZChild(this); } } @lombok.Builder.Default int a; @@ -133,16 +133,16 @@ class CheckerFrameworkSuperBuilder { private static @java.lang.SuppressWarnings("all") int $default$a() { return 1; } - protected @org.checkerframework.common.aliasing.qual.Unique @java.lang.SuppressWarnings("all") Child(final CheckerFrameworkSuperBuilder.Child.ChildBuilder b) { + protected @org.checkerframework.common.aliasing.qual.Unique @java.lang.SuppressWarnings("all") ZChild(final CheckerFrameworkSuperBuilder.ZChild.ZChildBuilder b) { super(b); if (b.a$set) this.a = b.a$value; else - this.a = CheckerFrameworkSuperBuilder.Child.$default$a(); + this.a = CheckerFrameworkSuperBuilder.ZChild.$default$a(); this.b = b.b; } - public static @org.checkerframework.common.aliasing.qual.Unique @java.lang.SuppressWarnings("all") CheckerFrameworkSuperBuilder.Child.ChildBuilder builder() { - return new CheckerFrameworkSuperBuilder.Child.ChildBuilderImpl(); + public static @org.checkerframework.common.aliasing.qual.Unique @java.lang.SuppressWarnings("all") CheckerFrameworkSuperBuilder.ZChild.ZChildBuilder builder() { + return new CheckerFrameworkSuperBuilder.ZChild.ZChildBuilderImpl(); } } CheckerFrameworkSuperBuilder() { diff --git a/test/transform/resource/after-ecj/EqualsAndHashCodeAnnotated.java b/test/transform/resource/after-ecj/EqualsAndHashCodeAnnotated.java new file mode 100644 index 00000000..4e377fb4 --- /dev/null +++ b/test/transform/resource/after-ecj/EqualsAndHashCodeAnnotated.java @@ -0,0 +1,53 @@ +import java.lang.annotation.*; +@lombok.EqualsAndHashCode class EqualsAndHashCodeAnnotated { + @Target(ElementType.TYPE_USE) @Retention(RetentionPolicy.SOURCE) @interface Annotated { + } + @Annotated int primitive; + @Annotated Object object; + int @Annotated [] primitiveValues; + int @Annotated [] @Annotated [] morePrimitiveValues; + Integer @Annotated [] objectValues; + Integer @Annotated [] @Annotated [] moreObjectValues; + EqualsAndHashCodeAnnotated() { + super(); + } + public @java.lang.Override @java.lang.SuppressWarnings("all") boolean equals(final java.lang.Object o) { + if ((o == this)) + return true; + if ((! (o instanceof EqualsAndHashCodeAnnotated))) + return false; + final EqualsAndHashCodeAnnotated other = (EqualsAndHashCodeAnnotated) o; + if ((! other.canEqual((java.lang.Object) this))) + return false; + if ((this.primitive != other.primitive)) + return false; + final java.lang.Object this$object = this.object; + final java.lang.Object other$object = other.object; + if (((this$object == null) ? (other$object != null) : (! this$object.equals(other$object)))) + return false; + if ((! java.util.Arrays.equals(this.primitiveValues, other.primitiveValues))) + return false; + if ((! java.util.Arrays.deepEquals(this.morePrimitiveValues, other.morePrimitiveValues))) + return false; + if ((! java.util.Arrays.deepEquals(this.objectValues, other.objectValues))) + return false; + if ((! java.util.Arrays.deepEquals(this.moreObjectValues, other.moreObjectValues))) + return false; + return true; + } + protected @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) { + return (other instanceof EqualsAndHashCodeAnnotated); + } + public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() { + final int PRIME = 59; + int result = 1; + result = ((result * PRIME) + this.primitive); + final java.lang.Object $object = this.object; + result = ((result * PRIME) + (($object == null) ? 43 : $object.hashCode())); + result = ((result * PRIME) + java.util.Arrays.hashCode(this.primitiveValues)); + result = ((result * PRIME) + java.util.Arrays.deepHashCode(this.morePrimitiveValues)); + result = ((result * PRIME) + java.util.Arrays.deepHashCode(this.objectValues)); + result = ((result * PRIME) + java.util.Arrays.deepHashCode(this.moreObjectValues)); + return result; + } +} \ No newline at end of file diff --git a/test/transform/resource/after-ecj/ValLambda.java b/test/transform/resource/after-ecj/ValLambda.java index 5b52869f..6b59bdbd 100644 --- a/test/transform/resource/after-ecj/ValLambda.java +++ b/test/transform/resource/after-ecj/ValLambda.java @@ -1,3 +1,5 @@ +import java.io.Serializable; + class ValLambda { static { final @lombok.val java.lang.Runnable foo = ((System.currentTimeMillis() > 0) ? (Runnable) () -> { @@ -16,8 +18,8 @@ class ValLambda { final @lombok.val java.lang.Runnable foo = (Runnable) () -> { }; } - public void easyIntersectionLambda() { - final @lombok.val java.lang.Runnable foo = (Runnable & java.io.Serializable) () -> { + public void intersectionLambda() { + final @lombok.val java.io.Serializable foo = (Runnable & Serializable) () -> { }; final @lombok.val java.io.Serializable bar = (java.io.Serializable & Runnable) () -> { }; diff --git a/test/transform/resource/before/CheckerFrameworkSuperBuilder.java b/test/transform/resource/before/CheckerFrameworkSuperBuilder.java index 54aefb37..ed9e14cb 100644 --- a/test/transform/resource/before/CheckerFrameworkSuperBuilder.java +++ b/test/transform/resource/before/CheckerFrameworkSuperBuilder.java @@ -12,7 +12,7 @@ class CheckerFrameworkSuperBuilder { } @lombok.experimental.SuperBuilder - public static class Child extends Parent { + public static class ZChild extends Parent { @lombok.Builder.Default int a = 1; int b; } diff --git a/test/transform/resource/before/ValLambda.java b/test/transform/resource/before/ValLambda.java index 5c9c4a43..e956bcd3 100644 --- a/test/transform/resource/before/ValLambda.java +++ b/test/transform/resource/before/ValLambda.java @@ -1,4 +1,6 @@ // version 8: +import java.io.Serializable; + class ValLambda { static { @@ -12,8 +14,8 @@ class ValLambda { lombok.val foo = (Runnable)()-> {}; } - public void easyIntersectionLambda() { - lombok.val foo = (Runnable & java.io.Serializable)()-> {}; + public void intersectionLambda() { + lombok.val foo = (Runnable & Serializable)()-> {}; lombok.val bar = (java.io.Serializable & Runnable)()-> {}; } diff --git a/test/transform/resource/before/ValLub.java b/test/transform/resource/before/ValLub.java index c1b41c26..509a4f8b 100644 --- a/test/transform/resource/before/ValLub.java +++ b/test/transform/resource/before/ValLub.java @@ -1,21 +1,21 @@ class ValLub { public void easyLub() { java.util.Map m = java.util.Collections.emptyMap(); - + lombok.val foo = (System.currentTimeMillis() > 0) ? m : java.util.Collections.emptyMap(); } - + public void sillyLubWithUnboxingThatProducesErrorThatVarIsPrimitive() { Integer i = 20; Double d = 20.0; - + lombok.val thisShouldBePrimitiveDouble = (System.currentTimeMillis() > 0) ? i : d; } - + public void hardLub() { java.util.List list = new java.util.ArrayList(); java.util.Set set = new java.util.HashSet(); - + lombok.val thisShouldBeCollection = (System.currentTimeMillis() > 0) ? list : set; thisShouldBeCollection.add(""); String foo = thisShouldBeCollection.iterator().next(); diff --git a/test/transform/resource/messages-ecj/ValLambda.java.messages b/test/transform/resource/messages-ecj/ValLambda.java.messages index e6940434..fa7231ef 100644 --- a/test/transform/resource/messages-ecj/ValLambda.java.messages +++ b/test/transform/resource/messages-ecj/ValLambda.java.messages @@ -1,2 +1,2 @@ -23 Function is a raw type. References to generic type Function should be parameterized -24 Function is a raw type. References to generic type Function should be parameterized \ No newline at end of file +24 Function is a raw type. References to generic type Function should be parameterized +25 Function is a raw type. References to generic type Function should be parameterized \ No newline at end of file -- cgit