lombok-intellij-plugin icon indicating copy to clipboard operation
lombok-intellij-plugin copied to clipboard

@Builder.Default-annotated fields excluded as parameters for @RequiredArgsConstructor-generated constructors

Open hwaite opened this issue 2 years ago • 1 comments

Short description

@RequiredArgsConstructor annotation generates a constructor that accepts parameters for all non-initialized members. Lombok plugin mistakenly recognizes fields with @Builder.Default annotation as initialized. From lombok-generated constructor's perspective, the @Builder.Default annotation invalidates inline initializations. IDEA 'Structure' pane shows constructor with missing parameters. Code relying on this 'false' constructor shows no errors. However, any code relying on the phantom constructor won't compile from javac.exe.

Expected behavior

IDEA should interpret class structure in the same way that compiler does.

Version information

  • IDEA Version: Build #IU-222.4459.24, built on November 22, 2022
  • JDK Version: openjdk version "17.0.2" 2022-01-18
  • OS Type & Version: Windows 11
  • Lombok Plugin Version: 222.4459.24
  • Lombok Dependency Version: 1.18.24

Steps to reproduce

What steps do we need to take to reproduce this issue?

@Value @Builder @RequiredArgsConstructor class Foo {
    String alpha;
    @Builder.Default
    String bravo = "x";
    static void bar() {new Foo("y");}
}
[ERROR] Foo.java:[10,29] constructor Foo in class Foo cannot be applied to given types;
[ERROR]   required: java.lang.String,java.lang.String
[ERROR]   found:    java.lang.String
[ERROR]   reason: actual and formal argument lists differ in length
missingparam

hwaite avatar Dec 25 '22 14:12 hwaite

See also #1110 and #1123.

hwaite avatar Dec 25 '22 14:12 hwaite