Javac false-positive in patterns for switch

Ilyas Selimov ilyas.selimov at jetbrains.com
Fri Sep 3 04:21:51 UTC 2021


Hello!

The code like

public class Test {
    String foo(int i) {
        return switch(i) {
            case Integer v -> "" + v;
            case default -> "";
        };
    }
}

seems shouldn't provide a compilation error,
but Javac (build 35) says "bad operand type int for unary operator
'<*nullchk*>'".
Could somebody take a look?

Thanks,
Ilyas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20210903/5c6ee3b7/attachment.htm>


More information about the compiler-dev mailing list