[Lombok] Constructor can have only non-final or not initialized fields

When using the AllArgsConstructor annotation (directly or via
meta-annotation), only fields that are not final or not initialized
should be added as arguments. Previously, all fields were being included
regardless of modality or initialization, which is not consistent with
the behavior of Lombok.

^KT-54054 Fixed
This commit is contained in:
Brian Norman
2024-01-11 13:30:00 -06:00
committed by Space Team
parent cf4c55e02d
commit 2ab1e712f8
4 changed files with 36 additions and 5 deletions
+8 -2
View File
@@ -5,11 +5,17 @@ import lombok.*;
@AllArgsConstructor
public class ConstructorExample {
// Part of constructor because not final.
@Getter @Setter private int age = 10;
// Part of constructor because not initialized.
@Getter(AccessLevel.PROTECTED) private String name;
private boolean otherField;
// Part of constructor because not initialized.
private final boolean otherField;
// Not part of constructor because final and initialized.
@Getter private final String result = "OK";
static void javaUsage() {
val generated = new ConstructorExample(12, "sdf", true);
@@ -21,5 +27,5 @@ public class ConstructorExample {
fun box(): String {
val generated = ConstructorExample(12, "sdf", true)
return "OK"
return generated.getResult()
}