Describe the bug
It looks like when HandleHelper.handle calls annotatedType.directUp(), if the class is nested immediately within a method then the result is the method. As this is not a block or a case statement, getStatementsFromJcNode returns null, and the handler fails with an error.
To Reproduce
With L1.java (the example in the docs):
import lombok.experimental.Helper;
public class L1 {
int someMethod(int arg1) {
int localVar = 5;
@Helper class Helpers {
int helperMethod(int arg) {
return arg + localVar;
}
}
return helperMethod(10);
}
}
I get
$ javac -cp lombok-1.18.26.jar L1.java
L1.java:7: error: @Helper is legal only on method-local classes.
@Helper class Helpers {
^
1 error
$
If I add an extra block around the body:
import lombok.experimental.Helper;
public class L2 {
int someMethod(int arg1) {
{
int localVar = 5;
@Helper class Helpers {
int helperMethod(int arg) {
return arg + localVar;
}
}
return helperMethod(10);
}
}
}
then it works:
$ javac -cp lombok-1.18.26.jar L2.java
$
Expected behavior
I expected the example to compile.
Version info (please complete the following information):
- Lombok version: 1.18.26
- Platform: javac 17.0.6
Describe the bug
It looks like when
HandleHelper.handlecallsannotatedType.directUp(), if the class is nested immediately within a method then the result is the method. As this is not a block or a case statement,getStatementsFromJcNodereturns null, and the handler fails with an error.To Reproduce
With L1.java (the example in the docs):
I get
If I add an extra block around the body:
then it works:
Expected behavior
I expected the example to compile.
Version info (please complete the following information):