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

False positive when using switch expressions on sealed interfaces. #2959

Open
computerscience-person opened this issue Nov 16, 2023 · 1 comment

Comments

@computerscience-person
Copy link

Hello, I was looking at some of my code and found that jdt-ls gives a false positive error when using switch expressions on sealed interfaces.

Example code snippet:

  public sealed interface Day permits SchoolDay, Weekend, Holiday {
  // SNIP
    default void summary() {
      switch (this) {
        case SchoolDay day -> {
          out.println("Finished school day.");
        }
        case Weekend day -> {
          out.println("Finished weekend.");
        }
        case Holiday day -> {
          out.println("Finished holiday.");
        }
      }
    }

Here, jdt-ls gives 7 errors:

  • Cannot switch on a value of type of this.
  • SchoolDay cannot be resolved to a variable.
  • Syntax error on token "day", delete this token.

And similar errors on the other two classes that implement the interface Day.

Apart from that, using sealed interfaces themselves are clunky, and needs better suggestions/code completions.

@snjeza
Copy link
Contributor

snjeza commented Nov 16, 2023

@computerscience-person Could you attach a project example?

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

2 participants