Skip to content
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

[19] ECJ reports switch with total record pattern as not exhaustive #398

Closed
jarthana opened this issue Sep 15, 2022 · 5 comments
Closed
Assignees
Milestone

Comments

@jarthana
Copy link
Member

jarthana commented Sep 15, 2022

Try this testcase:

public class VarPattern {
  record Person(String name, int age) {}
  public static void main(String[] args) {
    Person person = new Person("Bob", 12);
    switch (person) {
      case Person(var name, var age) -> System.out.println(name +  " " + age);
    }
  }
}

ECJ reports the switch to be not exhaustive and suggest adding a default case. But it's not required as we already have a total pattern in the record pattern Person(var name, var age). I suspect this is due to the unimplemented isTotalForType() in RecordPattern.

@jarthana jarthana added this to the BETA_JAVA19 milestone Sep 15, 2022
@jarthana jarthana self-assigned this Sep 15, 2022
@jarthana
Copy link
Member Author

I thought we can fix this simply by computing and storing isTotalTypeNode for a record pattern rather. But this had issues in code generation where we were using the same flag to mean whether the pattern is a subtype or not. So, we will have to make some changes in how we store and use this flag. I have a working patch, but needs more testing and considering how late we are in the game, would like to test it bit more. There's a chance this will only make it after the GA.

@kriegaex
Copy link
Contributor

Hello @jarthana, how much more testing and refinement is this issue going to take? Could this be fixed together with #455 anytime soon?

@jarthana
Copy link
Member Author

Hello @jarthana, how much more testing and refinement is this issue going to take? Could this be fixed together with #455 anytime soon?

Sorry, I should have updated. The earlier patch wasn't good enough. So, I left it at that. I believe this is same as #587 , which Manoj is looking at.

Copying @mpalat

@iloveeclipse
Copy link
Member

@jarthana : please close if fixed or set other milestone, BETA_JAVA19 is not valid anymore.

@jarthana jarthana modified the milestones: BETA_JAVA19, BETA_JAVA20 Feb 28, 2023
@mpalat mpalat modified the milestones: BETA_JAVA20, 4.28 Mar 22, 2023
@iloveeclipse iloveeclipse modified the milestones: 4.28, 4.29 Jun 8, 2023
@mpalat
Copy link
Contributor

mpalat commented Aug 16, 2023

yes, this is a duplicate - #1244 (along with #587 for further variations) fixes this.

@mpalat mpalat closed this as completed Aug 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants