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

Vicente Romero vromero at openjdk.org
Tue Jan 17 20:34:32 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.

looks sensible

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

Marked as reviewed by vromero (Reviewer).

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


More information about the compiler-dev mailing list