From 6f204d98c450092f4a6252677fc44657704b9897 Mon Sep 17 00:00:00 2001 From: Rawi01 Date: Mon, 13 Mar 2023 19:55:52 +0100 Subject: [fixes #3366] Handle @NonNull type annotations on record components --- test/transform/resource/after-delombok/NonNullOnRecord.java | 13 ------------- .../transform/resource/after-delombok/NonNullOnRecord2.java | 10 ---------- .../transform/resource/after-delombok/NonNullOnRecord3.java | 13 ------------- .../after-delombok/NonNullOnRecordExistingConstructor.java | 10 ++++++++++ .../after-delombok/NonNullOnRecordExistingSetter.java | 13 +++++++++++++ .../resource/after-delombok/NonNullOnRecordSimple.java | 13 +++++++++++++ .../resource/after-delombok/NonNullOnRecordTypeUse.java | 13 +++++++++++++ 7 files changed, 49 insertions(+), 36 deletions(-) delete mode 100644 test/transform/resource/after-delombok/NonNullOnRecord.java delete mode 100644 test/transform/resource/after-delombok/NonNullOnRecord2.java delete mode 100644 test/transform/resource/after-delombok/NonNullOnRecord3.java create mode 100644 test/transform/resource/after-delombok/NonNullOnRecordExistingConstructor.java create mode 100644 test/transform/resource/after-delombok/NonNullOnRecordExistingSetter.java create mode 100644 test/transform/resource/after-delombok/NonNullOnRecordSimple.java create mode 100644 test/transform/resource/after-delombok/NonNullOnRecordTypeUse.java (limited to 'test/transform/resource/after-delombok') diff --git a/test/transform/resource/after-delombok/NonNullOnRecord.java b/test/transform/resource/after-delombok/NonNullOnRecord.java deleted file mode 100644 index 465c30db..00000000 --- a/test/transform/resource/after-delombok/NonNullOnRecord.java +++ /dev/null @@ -1,13 +0,0 @@ -// version 16: -import lombok.NonNull; -public record NonNullOnRecord(@NonNull String a, @NonNull String b) { - @java.lang.SuppressWarnings("all") - public NonNullOnRecord { - if (a == null) { - throw new java.lang.NullPointerException("a is marked non-null but is null"); - } - if (b == null) { - throw new java.lang.NullPointerException("b is marked non-null but is null"); - } - } -} diff --git a/test/transform/resource/after-delombok/NonNullOnRecord2.java b/test/transform/resource/after-delombok/NonNullOnRecord2.java deleted file mode 100644 index d3021350..00000000 --- a/test/transform/resource/after-delombok/NonNullOnRecord2.java +++ /dev/null @@ -1,10 +0,0 @@ -// version 16: -import lombok.NonNull; -record NonNullOnRecord2(@NonNull String a) { - public NonNullOnRecord2 { - if (a == null) { - throw new java.lang.NullPointerException("a is marked non-null but is null"); - } - System.out.println("Hello"); - } -} diff --git a/test/transform/resource/after-delombok/NonNullOnRecord3.java b/test/transform/resource/after-delombok/NonNullOnRecord3.java deleted file mode 100644 index 62b385bc..00000000 --- a/test/transform/resource/after-delombok/NonNullOnRecord3.java +++ /dev/null @@ -1,13 +0,0 @@ -// version 14: -import lombok.NonNull; -public record NonNullOnRecord3(@NonNull String a) { - public NonNullOnRecord3(String a) { - this.a = a; - } - public void method(@NonNull String param) { - if (param == null) { - throw new java.lang.NullPointerException("param is marked non-null but is null"); - } - String asd = "a"; - } -} diff --git a/test/transform/resource/after-delombok/NonNullOnRecordExistingConstructor.java b/test/transform/resource/after-delombok/NonNullOnRecordExistingConstructor.java new file mode 100644 index 00000000..e3fdc2fc --- /dev/null +++ b/test/transform/resource/after-delombok/NonNullOnRecordExistingConstructor.java @@ -0,0 +1,10 @@ +// version 16: +import lombok.NonNull; +public record NonNullOnRecordExistingConstructor(@NonNull String a) { + public NonNullOnRecordExistingConstructor { + if (a == null) { + throw new java.lang.NullPointerException("a is marked non-null but is null"); + } + System.out.println("Hello"); + } +} diff --git a/test/transform/resource/after-delombok/NonNullOnRecordExistingSetter.java b/test/transform/resource/after-delombok/NonNullOnRecordExistingSetter.java new file mode 100644 index 00000000..11aaca49 --- /dev/null +++ b/test/transform/resource/after-delombok/NonNullOnRecordExistingSetter.java @@ -0,0 +1,13 @@ +// version 14: +import lombok.NonNull; +public record NonNullOnRecordExistingSetter(@NonNull String a) { + public NonNullOnRecordExistingSetter(String a) { + this.a = a; + } + public void method(@NonNull String param) { + if (param == null) { + throw new java.lang.NullPointerException("param is marked non-null but is null"); + } + String asd = "a"; + } +} diff --git a/test/transform/resource/after-delombok/NonNullOnRecordSimple.java b/test/transform/resource/after-delombok/NonNullOnRecordSimple.java new file mode 100644 index 00000000..2a772c93 --- /dev/null +++ b/test/transform/resource/after-delombok/NonNullOnRecordSimple.java @@ -0,0 +1,13 @@ +// version 16: +import lombok.NonNull; +public record NonNullOnRecordSimple(@NonNull String a, @NonNull String b) { + @java.lang.SuppressWarnings("all") + public NonNullOnRecordSimple { + if (a == null) { + throw new java.lang.NullPointerException("a is marked non-null but is null"); + } + if (b == null) { + throw new java.lang.NullPointerException("b is marked non-null but is null"); + } + } +} diff --git a/test/transform/resource/after-delombok/NonNullOnRecordTypeUse.java b/test/transform/resource/after-delombok/NonNullOnRecordTypeUse.java new file mode 100644 index 00000000..e5b78f1c --- /dev/null +++ b/test/transform/resource/after-delombok/NonNullOnRecordTypeUse.java @@ -0,0 +1,13 @@ +// version 16: +import lombok.NonNull; +public record NonNullOnRecordTypeUse(@NonNull int[] a, int @NonNull [] b, int[] @NonNull [] c) { + @java.lang.SuppressWarnings("all") + public NonNullOnRecordTypeUse { + if (a == null) { + throw new java.lang.NullPointerException("a is marked non-null but is null"); + } + if (b == null) { + throw new java.lang.NullPointerException("b is marked non-null but is null"); + } + } +} -- cgit