[jdk20] Integrated: 8300195: Fall-through issue occurs when using record pattern in switch statements

Jan Lahoda jlahoda at openjdk.org
Wed Jan 18 10:47:25 UTC 2023


On Mon, 16 Jan 2023 15:11:12 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:

> 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.

This pull request has now been integrated.

Changeset: c1b4212a
Author:    Jan Lahoda <jlahoda at openjdk.org>
URL:       https://git.openjdk.org/jdk20/commit/c1b4212a53e5d26108e560a82250b01689ae03f0
Stats:     126 lines in 2 files changed: 115 ins; 4 del; 7 mod

8300195: Fall-through issue occurs when using record pattern in switch statements

Reviewed-by: vromero

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

PR: https://git.openjdk.org/jdk20/pull/109


More information about the compiler-dev mailing list