diff options
5 files changed, 34 insertions, 4 deletions
@@ -7,6 +7,7 @@ Dave Brosius <dbrosius@mebigfatguy.com> Dawid Rusin <dawidrusin90@gmail.com> Enrique da Costa Cambio <enrique.dacostacambio@gmail.com> Jappe van der Hel <jappe.vanderhel@gmail.com> +Kevin Chirls <kchirls@users.noreply.github.com> Liu DongMiao <liudongmiao@gmail.com> Luan Nico <luannico27@gmail.com> Maarten Mulders <mthmulders@users.noreply.github.com> diff --git a/src/core/lombok/eclipse/handlers/HandleConstructor.java b/src/core/lombok/eclipse/handlers/HandleConstructor.java index 49b09231..072b6dd5 100644 --- a/src/core/lombok/eclipse/handlers/HandleConstructor.java +++ b/src/core/lombok/eclipse/handlers/HandleConstructor.java @@ -347,7 +347,7 @@ public class HandleConstructor { Annotation[] nonNulls = findAnnotations(field, NON_NULL_PATTERN); Annotation[] nullables = findAnnotations(field, NULLABLE_PATTERN); if (nonNulls.length != 0) { - Statement nullCheck = generateNullCheck(field, sourceNode); + Statement nullCheck = generateNullCheck(parameter, sourceNode); if (nullCheck != null) nullChecks.add(nullCheck); } parameter.annotations = copyAnnotations(source, nonNulls, nullables); diff --git a/test/transform/resource/after-delombok/ConstructorsWithAccessors.java b/test/transform/resource/after-delombok/ConstructorsWithAccessors.java index 25455943..6e9398ba 100644 --- a/test/transform/resource/after-delombok/ConstructorsWithAccessors.java +++ b/test/transform/resource/after-delombok/ConstructorsWithAccessors.java @@ -23,12 +23,11 @@ class NonNullConstructorsWithAccessors { @lombok.NonNull Integer _huh; @lombok.NonNull - Integer __huh2; + final Integer __huh2; @java.beans.ConstructorProperties({"plower", "upper", "huh", "_huh2"}) @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") - @lombok.Generated public NonNullConstructorsWithAccessors(@lombok.NonNull final Integer plower, @lombok.NonNull final Integer upper, @lombok.NonNull final Integer huh, @lombok.NonNull final Integer _huh2) { if (plower == null) { throw new java.lang.NullPointerException("plower"); diff --git a/test/transform/resource/after-ecj/ConstructorsWithAccessors.java b/test/transform/resource/after-ecj/ConstructorsWithAccessors.java index 7c691b42..b7a20e18 100644 --- a/test/transform/resource/after-ecj/ConstructorsWithAccessors.java +++ b/test/transform/resource/after-ecj/ConstructorsWithAccessors.java @@ -11,3 +11,33 @@ this.__huh2 = _huh2; } } +@lombok.AllArgsConstructor @lombok.experimental.Accessors(prefix = {"p", "_"}) class NonNullConstructorsWithAccessors { + @lombok.NonNull Integer plower; + @lombok.NonNull Integer pUpper; + @lombok.NonNull Integer _huh; + final @lombok.NonNull Integer __huh2; + public @java.beans.ConstructorProperties({"plower", "upper", "huh", "_huh2"}) @java.lang.SuppressWarnings("all") @javax.annotation.Generated("lombok") NonNullConstructorsWithAccessors(final @lombok.NonNull Integer plower, final @lombok.NonNull Integer upper, final @lombok.NonNull Integer huh, final @lombok.NonNull Integer _huh2) { + super(); + if ((plower == null)) + { + throw new java.lang.NullPointerException("plower"); + } + if ((upper == null)) + { + throw new java.lang.NullPointerException("upper"); + } + if ((huh == null)) + { + throw new java.lang.NullPointerException("huh"); + } + if ((_huh2 == null)) + { + throw new java.lang.NullPointerException("_huh2"); + } + this.plower = plower; + this.pUpper = upper; + this._huh = huh; + this.__huh2 = _huh2; + } +} + diff --git a/test/transform/resource/before/ConstructorsWithAccessors.java b/test/transform/resource/before/ConstructorsWithAccessors.java index 6facb03a..12221ab7 100644 --- a/test/transform/resource/before/ConstructorsWithAccessors.java +++ b/test/transform/resource/before/ConstructorsWithAccessors.java @@ -9,6 +9,6 @@ @lombok.NonNull Integer plower; @lombok.NonNull Integer pUpper; @lombok.NonNull Integer _huh; - @lombok.NonNull Integer __huh2; + @lombok.NonNull final Integer __huh2; } |