eclipse.jdt.ls
eclipse.jdt.ls copied to clipboard
False positive when using switch expressions on sealed interfaces.
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.
@computerscience-person Could you attach a project example?