-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Patterns][Java22] Abstraction gap in modelling multi case patterns #2069
Comments
The main rationale for connecting the guard to the CaseStatement instead of some new construct would be to match how it's specified in the spec (see 14.11.1 Switch Blocks in https://docs.oracle.com/javase/specs/jls/se21/preview/specs/unnamed-jls.html, but note that they use the name "SwitchLabel" instead of CaseStatement) |
I can see the guard being attached to the Academic point: I was wondering why we need an abstraction for |
That guards enter the picture only with patterns (i.e. you can't say BTW, the original |
Re-reading 14.11.1 Switch Blocks, it is clear that JLS intends guards to be attached to switch rules and not patterns. So you are right there @datho7561 - but for reasons discussed above, I will leave status quo undisturbed. It doesn't make a material difference as far as I can see. |
As of commit 684524f made as part of PR #2011 we have a working compiler implementation for multiple patterns in a case statement.
However as @datho7561 points out in review feedback here #2011 (review) and acknowledged here #2011 (comment) AST clients will need a better abstraction.
The proposal is to come with a new class
EitherOrMultiPattern
which can stand on its own when there is no guard in the source or be theprimaryPattern
of aGuardedPattern
otherwise,On the DOM side, we will need the dopplegangers of course,
The text was updated successfully, but these errors were encountered: