[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
+7 -1
View File
@@ -5,12 +5,18 @@ import lombok.*;
@AllArgsConstructor(staticName = "of")
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;
// Part of constructor because not initialized.
private boolean otherField;
// Not part of constructor because final and initialized.
@Getter private final String result = "OK";
public ConstructorExample(String arg) {
}
@@ -27,5 +33,5 @@ public class ConstructorExample {
fun box(): String {
val existing: ConstructorExample = ConstructorExample("existing")
val generated: ConstructorExample = ConstructorExample.of(45, "234", false)
return "OK"
return generated.getResult()
}