RFR: 8314578: Non-verifiable code is emitted when two guards declare pattern variables in colon-switch
Angelos Bimpoudis
angelos.bimpoudis at oracle.com
Mon Oct 2 18:19:00 UTC 2023
Hello Rémi,
https://github.com/openjdk/jdk/pull/15630/files#diff-06a9cd077d1cc0d23cc8810100b1ac02ac2a19904581f809bc79b49582971f69R35-R42
I added that pos test. I think this should compile ok (already did). Do I understand correctly?
Angelos.
________________________________
From: Remi Forax <forax at univ-mlv.fr>
Sent: 02 October 2023 17:04
To: Aggelos Biboudis <abimpoudis at openjdk.org>
Cc: compiler-dev <compiler-dev at openjdk.org>
Subject: Re: RFR: 8314578: Non-verifiable code is emitted when two guards declare pattern variables in colon-switch
----- 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/compiler-dev/attachments/20231002/d1d5e451/attachment.htm>
More information about the compiler-dev
mailing list