IDEA-203812 bad code green: switch expression does not have any case clauses

This commit is contained in:
Tagir Valeev
2018-12-08 16:56:57 +07:00
parent 6ea7ea44c2
commit 244c7f0164
2 changed files with 7 additions and 1 deletions
@@ -1996,7 +1996,7 @@ public class HighlightUtil extends HighlightUtilBase {
Set<String> missingConstants = new HashSet<>();
boolean exhaustive = hasDefaultCase;
if (!exhaustive) {
if (selectorType instanceof PsiClassType) {
if (!values.isEmpty() && selectorType instanceof PsiClassType) {
PsiClass type = ((PsiClassType)selectorType).resolve();
if (type != null && type.isEnum()) {
for (PsiField field : type.getFields()) {
@@ -58,4 +58,10 @@ class SwitchExpressions {
});
}
}
enum Empty {}
boolean testEmpty(Empty e) {
return switch (<error descr="'switch' expression does not have any case clauses">e</error>) {};
}
}