Search code examples
javaintellij-idealombokintellij-14intellij-lombok-plugin

Fluent getters generate errors


I have a project with the following lombok.config file:

lombok.accessors.chain = true
lombok.accessors.fluent = true

So the following class should compile fine:

@Data class A {
  private int i;
  public static void main(String[] args) {
    new A().i();
  }
}

and it does when compiling with javac. But Intellij (with or without the lombok plugin) shows a compilation error and the auto completion suggests using getI() which does not exist.

How can I fix this?


Solution

  • I think you're facing issue 53.

    As a workaround, you could use @Accessors:

    @Accessors(fluent = true) // order matters
    @Data
    class A {
        private int i;
        public static void main(String[] args) {
            new A().i();
        }
    }
    

    compile fine here (IntelliJ 14.0.3, lombok-plugin 0.8.9)