Java: Fix CFG for rule statements.

This commit is contained in:
Anders Schack-Mulligen
2023-09-28 14:19:36 +02:00
parent 922a4e8ddf
commit 917a15647e
2 changed files with 11 additions and 1 deletions

View File

@@ -871,7 +871,13 @@ private module ControlFlowGraphImpl {
)
or
// the last node in a case rule is the last node in the right-hand side
last(n.(SwitchCase).getRuleStatement(), last, completion)
// if the rhs is a statement we wrap the completion as a break
exists(Completion caseCompletion |
last(n.(SwitchCase).getRuleStatement(), last, caseCompletion) and
if caseCompletion instanceof NormalOrBooleanCompletion
then completion = anonymousBreakCompletion()
else completion = caseCompletion
)
or
// ...and if the rhs is an expression we wrap the completion as a yield
exists(Completion caseCompletion |