[jdk20] RFR: 8300195: Fall-through issue occurs when using record pattern in switch statements
Jan Lahoda
jlahoda at openjdk.org
Mon Jan 16 15:21:58 UTC 2023
When converting pattern matching switches, cases with common prefix tests are factored out into separate sub-switches. But, when this happens, the cases generated are the statement cases, even if the original cases where rule cases. So, this may lead to an unintended fall through. The proposal here is to inject breaks with correct targets as needed.
Alternatively, we could keep the kind of the cases, but that is more tricky, as the cases must break the main switch, not the nested ones.
-------------
Commit messages:
- 8300195: Fall-through issue occurs when using record pattern in switch statements
Changes: https://git.openjdk.org/jdk20/pull/109/files
Webrev: https://webrevs.openjdk.org/?repo=jdk20&pr=109&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8300195
Stats: 124 lines in 2 files changed: 113 ins; 4 del; 7 mod
Patch: https://git.openjdk.org/jdk20/pull/109.diff
Fetch: git fetch https://git.openjdk.org/jdk20 pull/109/head:pull/109
PR: https://git.openjdk.org/jdk20/pull/109
More information about the compiler-dev
mailing list