简体   繁体   中英

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:

在此处输入图片说明

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

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. 在此处输入图片说明


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

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

You should turn off the Lombok annotations inspection until they fix the issue.

在此处输入图片说明 在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM