Search code examples
javaintellij-ideaintellij-pluginintellij-lombok-pluginjava-11

IntelliJ IDEa 2018.2 highlights var lambda parameter as error using JDK 11


Tested on Oracle JDK 11 and latest (as of now) available version of IntelliJ IDEa (IntelliJ IDEA 2018.2.4). Project language level is Java 11.

Code

public static void main(String[] args) {
    System.out.println(List.of("AAA", "BBB", "CCC")
            .stream()
            .map((@NonNull var s) -> s.toLowerCase())
            .collect(Collectors.toList()));
}

Output

[aaa, bbb, ccc]

Everything compiles and runs fine, but editor shows compile-time error:

enter image description here

Is JEP-323 (Local-Variable Syntax for Lambda Parameters) not yet supported or it's a bug?


Solution

  • If you have this error, you most likely have the Lombok plugin installed. It is a Lombok plugin inspection bug.

    Disabling the following inspection will fix the problem:

    File | Settings | Editor | Probable bugs | Lombok annotations inspection

    Also inspection can be implicitly suppressed. enter image description here


    The issue in Lombok-intellij-plugin project has been created:

    https://github.com/mplushnikov/lombok-intellij-plugin/issues/531