RFR: 8314578: Non-verifiable code is emitted when two guards declare pattern variables in colon-switch
Remi Forax
forax at univ-mlv.fr
Mon Oct 2 15:04:47 UTC 2023
----- Original Message -----
> From: "Aggelos Biboudis" <abimpoudis at openjdk.org>
> To: "compiler-dev" <compiler-dev at openjdk.org>
> Sent: Monday, October 2, 2023 12:19:40 PM
> Subject: RFR: 8314578: Non-verifiable code is emitted when two guards declare pattern variables in colon-switch
> In the following example while the case pattern does not introduce binding
> variable, the guard does. `hasBindings` has been updated accordingly to accept
> any trees and check them if they contain a `visitBindingPattern`. Not only
> `JCPattern`'s.
>
>
> static void test(Object o) {
> switch (o) {
> case R1() when o instanceof String s:
> case R2() when o instanceof Integer i:
> System.out.println("hello: " + i);
> break;
> default:
> break;
> }
> }
I think, i've fully understand the issue, what about
static void test(Object o) {
switch (o) {
case R1() when o instanceof String _:
case R2() when o instanceof Integer _:
System.out.println("hello: " + i);
break;
default:
break;
}
}
regards,
Rémi
>
> -------------
>
> Commit messages:
> - 8314578: Non-verifiable code is emitted when two guards declare pattern
> variables in colon-switch
>
> Changes: https://git.openjdk.org/jdk/pull/15630/files
> Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=15630&range=00
> Issue: https://bugs.openjdk.org/browse/JDK-8314578
> Stats: 41 lines in 3 files changed: 38 ins; 0 del; 3 mod
> Patch: https://git.openjdk.org/jdk/pull/15630.diff
> Fetch: git fetch https://git.openjdk.org/jdk.git pull/15630/head:pull/15630
>
> PR: https://git.openjdk.org/jdk/pull/15630
More information about the compiler-dev
mailing list