[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:
+8
-2
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user