lvti: reject initializing var with void (IDEA-188623)

This commit is contained in:
Anna.Kozlova
2018-03-20 19:58:02 +01:00
parent ba3eb90b09
commit 924e032bbf
2 changed files with 8 additions and 0 deletions
@@ -462,6 +462,12 @@ public class HighlightUtil extends HighlightUtilBase {
.descriptionAndTooltip("Cannot infer type: variable initializer is 'null'")
.range(typeElement).create();
}
if (PsiType.VOID.equals(lType)) {
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR)
.descriptionAndTooltip("Cannot infer type: variable initializer is 'void'")
.range(typeElement).create();
}
}
}
return null;
@@ -33,6 +33,8 @@ class Main {
var runnable = true ? <error descr="Lambda expression not expected here">() -> {}</error> : <error descr="Lambda expression not expected here">() -> {}</error>;
Function<String, String> f1 = (<error descr="Cannot resolve symbol 'var'">var</error> var) -> var;
<error descr="Cannot infer type: variable initializer is 'void'">var</error> h = localVariableDeclaration();
}
private void forEachType(String[] strs, Iterable<String> it, Iterable raw) {