eclipse-jdt / eclipse-jdt/eclipse.jdt.core
[Switch Expressions] Poor quality diagnostics
- Dominant language
- Java
- Stars
- 237
- Forks
- 195
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 47
Description
This program generates two errors:
* Syntax error, insert ";" to complete LocalVariableDeclarationStatement
* Syntax error on token "yield", AssignmentOperator expected after this token
```
public class X {
public static void main(String[] args) {
Object x = "Hello";
String j = switch (x) {
case String s : yield "String";
default : { System.out.println();
yield "Default";
}
}
}
}
```
The second one is not helpful and head scratch inducing.
(2) This program generates: `C cannot be resolved or is not a field` which is not quite the case even though the error is valid.
```
public class X {
enum E1 {
A;
}
enum E2 {
B;
}
public static final int C = 42;
public static void main(String[] args) {
}
void foo(E1 e1) {
switch (e1) {
case A :
case C :
}
System.out.println(C);
}
}
```
Contributor guide
Assessment
This issue has not been assessed yet.