Skip to content

Fix lookahead for pattern expression in switch entries [Issue 4455]#4458

Merged
jlerbsc merged 3 commits intojavaparser:masterfrom
johannescoetzee:johannes/fix-pattern-lookahead
Jun 6, 2024
Merged

Fix lookahead for pattern expression in switch entries [Issue 4455]#4458
jlerbsc merged 3 commits intojavaparser:masterfrom
johannescoetzee:johannes/fix-pattern-lookahead

Conversation

@johannescoetzee
Copy link
Copy Markdown
Collaborator

Fixes #4455.

The bug was that the LOOKAHEAD(3) (or in general any fixed-distance lookahead) is not sufficient to determine whether Foo.Bar.Baz. ... is a field access expression or a nested type name. Without knowledge about the next symbol, CustomDeployTableModel.ARTIFACT_NAME could just be the name of an inner class ARTIFACT_NAME

With this PR, I've changed the lookahead to check whether the next tokens describe a pattern expression, which could be slow for long expressions, but will keep inspecting tokens until the answer is unambiguous.

@johannescoetzee johannescoetzee changed the title Fix lookahead for pattern expression in switch entries Fix lookahead for pattern expression in switch entries [Issue 4455] Jun 6, 2024
@jlerbsc jlerbsc merged commit 6f074d1 into javaparser:master Jun 6, 2024
@jlerbsc jlerbsc added this to the next release milestone Jun 6, 2024
@jlerbsc jlerbsc added the PR: Fixed A PR that offers a fix or correction label Jun 6, 2024
@jlerbsc
Copy link
Copy Markdown
Collaborator

jlerbsc commented Jun 6, 2024

Thank for this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: Fixed A PR that offers a fix or correction

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Classic switch broken

2 participants