-
Notifications
You must be signed in to change notification settings - Fork 1
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
Parse multiple Patterns in a case statement #9
Parse multiple Patterns in a case statement #9
Conversation
Code generation is added |
3680e69
to
80a8db4
Compare
46fd077
to
96b986d
Compare
Can you rebase this PR onto |
80a8db4
to
804d22c
Compare
Please don't merge yet I still need to test it with JDT-LS |
I tried editing and running this class in jdt.ls, and it seems to be working as expected: public class MyClass {
public static void main(String... args) {
MyRecord<?> my_record = new MyRecord(null);
switch (my_record) {
case MyRecord(Chartreuse _), MyRecord(Licorice _):
System.out.println("sweet");
break;
case MyRecord(Cilantro _):
System.out.println("savory");
break;
default:
System.out.println("yikes");
break;
}
}
}
record MyRecord<T extends Flavour>(T f){}
sealed abstract class Flavour permits Cilantro, Licorice, Chartreuse {
}
final class Cilantro extends Flavour {}
final class Licorice extends Flavour {}
final class Chartreuse extends Flavour {} I'll do another rebase. |
Fixes eclipse-jdt#1804 Signed-off-by: David Thompson <[email protected]>
Second part of JEP 443. Change the parser so that it can parse a list of Patterns in a case. Change GuardedPattern AST (internal and and API) so that it has a list of patterns as its child instead of just one. Modify some tests that use record patterns with a variable (eg. `MyPoint(int x, int y) p` vs `MyPoint(int x, int y)`), since this syntax was only ever used in the preview version of the feature and is no longer allowed. Signed-off-by: David Thompson <[email protected]>
Signed-off-by: David Thompson <[email protected]>
Pushing the rebase soon. I have the following 3 failures and 3 errors when running this change in the jdt.ls test suite:
|
804d22c
to
1fd1a8e
Compare
@rgrunber FYI, one of the commits I include in this PR is a PR upstream, but that PR became stale due to changes in Pattern code generation, so I completely rewrote the upstream PR. eclipse-jdt#2016 |
We should use Srikanth's PR from upstream, which contains many bug fixes that Srikanth and I have written to this feature. I'll open a PR here, so that if we want to include it in incubator, we can. |
Second part of JEP 443.
MyPoint(int x, int y) p
vsMyPoint(int x, int y)
), since this syntax was only ever used in the preview version of the feature and is no longer allowed.Signed-off-by: David Thompson [email protected]