Do not suggest List<Void> type

Reported in IDEA-238075

GitOrigin-RevId: 3dc190cde20482c015321ba02a54adb0c238af46
This commit is contained in:
Tagir Valeev
2020-04-22 17:02:22 +07:00
committed by intellij-monorepo-bot
parent 4a4734d1ee
commit 78309def42
2 changed files with 14 additions and 0 deletions

View File

@@ -103,6 +103,9 @@ public class VariableTypeFromCallFix implements IntentionAction {
parameters,
expressions, PsiSubstitutor.EMPTY, resolved,
DefaultParameterTypeInferencePolicy.INSTANCE);
if (psiSubstitutor.getSubstitutionMap().values().stream().anyMatch(t -> t.equalsToText(CommonClassNames.JAVA_LANG_VOID))) {
continue;
}
final PsiType appropriateVarType = GenericsUtil.getVariableTypeByExpressionType(JavaPsiFacade.getElementFactory(
project).createType(varClass, psiSubstitutor));
if (!varType.equals(appropriateVarType)) {

View File

@@ -0,0 +1,11 @@
// "Change variable 'l' type to 'List<Void>'" "false"
import java.util.List;
public class Test {
void foo() {
List<String> l = null;
l.add(b<caret>ar());
}
void bar() {
}
}