[lombok] IDEA-255688 Using existing functionality to skip checking expressions from field initializer

and to skip checking field initializer expression

GitOrigin-RevId: 67211ecbad65889dabe6385678cc1b7c47a96deb
This commit is contained in:
Michail Plushnikov
2023-12-05 19:35:04 +01:00
committed by intellij-monorepo-bot
parent 7b19a2dd37
commit 4222be044e
11 changed files with 47 additions and 136 deletions

View File

@@ -14,6 +14,7 @@ public class GetterLazyInvocationProduceNPE {
}
private Bar <warning descr="Field 'bar' may be 'final'">bar</warning>;
private Bar <warning descr="Private field 'bar2' is never assigned">bar2</warning>;
private Car car;
public GetterLazyInvocationProduceNPE(Bar bar, Car car) {
@@ -21,11 +22,15 @@ public class GetterLazyInvocationProduceNPE {
this.car = car;
}
// without warning
// without warning, because of lazy getter and initialized in constructor
@Getter(lazy = true)
private final String barString = bar.sayHello();
//with warning!
// with warning, because of lazy getter and NOT initialized in constructor
@Getter(lazy = true)
private final String bar2String = bar2.<warning descr="Method invocation 'sayHello' will produce 'NullPointerException'">sayHello</warning>();
//with warning, because of NOT lazy getter
@Getter
private final String carString = car.<warning descr="Method invocation 'sayHello' will produce 'NullPointerException'">sayHello</warning>();