RFR: 8314578: Non-verifiable code is emitted when two guards declare pattern variables in colon-switch [v2]

Aggelos Biboudis abimpoudis at openjdk.org
Mon Oct 2 16:07:56 UTC 2023


> 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;
>     }
>   }

Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision:

  Add test with unnamed in guard

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/15630/files
  - new: https://git.openjdk.org/jdk/pull/15630/files/6cb25ea7..17c04251

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=15630&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=15630&range=00-01

  Stats: 13 lines in 2 files changed: 12 ins; 1 del; 0 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