switch expression: display dedicated error on target type void (IDEA-203776)

This commit is contained in:
Anna.Kozlova
2018-12-07 20:13:41 +01:00
parent 9eee56e6b1
commit 6692c339e1
2 changed files with 8 additions and 0 deletions
@@ -1452,6 +1452,10 @@ public class HighlightUtil extends HighlightUtilBase {
.create());
}
}
if (PsiType.VOID.equals(switchExpressionType)) {
infos.add(HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(switchExpression.getFirstChild()).descriptionAndTooltip("Target type for switch expression cannot be void").create());
}
}
return infos;
@@ -103,5 +103,9 @@ no instance(s) of type variable(s) exist so that Integer conforms to String">()
};
}
};
Runnable r = () -> <error descr="Target type for switch expression cannot be void">switch</error>(0) {
default -> throw new IllegalArgumentException();
};
}
}