[jdk17] RFR: 8268663: Crash when guards contain boolean expression [v2]

Jan Lahoda jlahoda at openjdk.java.net
Mon Jun 14 18:04:58 UTC 2021


On Mon, 14 Jun 2021 14:51:52 GMT, Vicente Romero <vromero at openjdk.org> wrote:

>> Jan Lahoda has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Adding tests as suggested on the review.
>
> test/langtools/tools/javac/patterns/Guards.java line 98:
> 
>> 96:         Object o2 = "";
>> 97:         switch (o) {
>> 98:             case Integer i && i == 0 && i < 1 && o2 instanceof String s: o = s + String.valueOf(i); return "true";
> 
> hi, I would recommend adding more tests with `||` in the condition, and with more than one case in the switch with conditions

Thanks, Vicente. I've added tests with `||` in https://github.com/openjdk/jdk17/pull/41/commits/d9e902b02b8a9916954fe4d2b665d4eaee3fb352 . One thing to note is that the tests are a bit different when writing something like: `case String s && s.isEmpty() || o2 instanceof Number n ->` `n` is not available here, as there is a path on which `o2` is not a `Number`.

-------------

PR: https://git.openjdk.java.net/jdk17/pull/41


More information about the compiler-dev mailing list