Files
kotlin-fork/plugins/lombok/testData/box/allArgsConstructor.kt
T
Brian Norman be728d4291 [Lombok] Constructor can have only non-static fields
When using the AllArgsConstructor annotation (directly or via
meta-annotation), only fields that are not static should be added as
arguments. Previously, all fields were being included regardless of
static-ness, which is not consistent with the behavior of Lombok.

^KT-54025 Fixed
2024-01-12 14:55:24 +00:00

35 lines
825 B
Kotlin
Vendored

// FILE: ConstructorExample.java
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;
// Part of constructor because not initialized.
private final boolean otherField;
// Not part of constructor because final and initialized.
@Getter private final String result = "OK";
// Not part of constructor because static.
private static String constant;
static void javaUsage() {
val generated = new ConstructorExample(12, "sdf", true);
}
}
// FILE: test.kt
fun box(): String {
val generated = ConstructorExample(12, "sdf", true)
return generated.getResult()
}