Closed
Description
In the following example, the check UnnecessaryDefaultInEnumSwitch suggests to remove the default
clause with the reason "Switch handles all enum values: the default case can be omitted to enable enforcement at compile-time that the switch statement is exhaustive." But the code would not compile then:
public class Test {
enum TestEnum {
FOO,
BAR;
}
void unnecessaryDefault() {
String x;
switch (TestEnum.FOO) {
case FOO -> x = "FOO";
case BAR -> x = "BAR";
default -> throw new AssertionError();
}
System.out.println(x);
}
}
It seems the reason is the incomplete handling of arrow rules from e5d52dd in
Metadata
Metadata
Assignees
Labels
No labels