diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/value/DfaExpressionFactory.java b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/value/DfaExpressionFactory.java index e10b204eeaa1..9be8a4e41092 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/value/DfaExpressionFactory.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/value/DfaExpressionFactory.java @@ -32,7 +32,6 @@ import com.intellij.psi.util.PropertyUtilBase; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.PsiUtil; import com.intellij.util.containers.ContainerUtil; -import com.siyeh.ig.psiutils.ExpectedTypeUtils; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -62,7 +61,7 @@ public class DfaExpressionFactory { } private final DfaValueFactory myFactory; - private final Map myMockIndices = ContainerUtil.newHashMap(); + private final Map myMockIndices = ContainerUtil.newHashMap(); public DfaExpressionFactory(DfaValueFactory factory) { myFactory = factory; @@ -129,14 +128,7 @@ public class DfaExpressionFactory { private DfaValue createReferenceValue(@NotNull PsiReferenceExpression refExpr) { PsiModifierListOwner var = getAccessedVariableOrGetter(refExpr.resolve()); if (var == null) { - if (!(refExpr.getParent() instanceof PsiMethodCallExpression)) { - String name = refExpr.getReferenceName(); - PsiType expectedType = ExpectedTypeUtils.findExpectedType(refExpr, false); - if (name != null && expectedType != null) { - var = myMockIndices.computeIfAbsent(name, n -> new LightVariableBuilder<>("$unresolved$" + n, expectedType, refExpr)); - } - } - if (var == null) return null; + return null; } if (!var.hasModifierProperty(PsiModifier.VOLATILE)) { @@ -220,7 +212,8 @@ public class DfaExpressionFactory { private PsiVariable getArrayIndexVariable(@Nullable PsiExpression indexExpression) { Object constant = JavaConstantExpressionEvaluator.computeConstantExpression(indexExpression, false); if (constant instanceof Integer && ((Integer)constant).intValue() >= 0) { - return myMockIndices.computeIfAbsent(constant, k -> new LightVariableBuilder<>("$array$index$" + k, PsiType.INT, indexExpression)); + return myMockIndices + .computeIfAbsent((Integer)constant, k -> new LightVariableBuilder<>("$array$index$" + k, PsiType.INT, indexExpression)); } return null; } diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/UnresolvedInTernary.java b/java/java-tests/testData/inspection/dataFlow/fixture/UnresolvedInTernary.java deleted file mode 100644 index 41b88873acaa..000000000000 --- a/java/java-tests/testData/inspection/dataFlow/fixture/UnresolvedInTernary.java +++ /dev/null @@ -1,61 +0,0 @@ -import java.util.*; - -public class UnresolvedInTernary { - void sideEffect() { - System.out.println("side effect"); - } - - void sideEffectTest() { - if(test) { - if(test) { - sideEffect(); - } - if(test) { - sideEffect(); - } - } - } - - List getList() { - return Arrays.asList( - test ? null : 1, - test ? null : 2, - test ? null : 3, - test ? null : 4, - test ? null : 5, - test ? null : 6, - test ? null : 7, - test ? null : 8, - test ? null : 9, - test ? null : 10, - test ? null : 11, - test ? null : 12, - test ? null : 13, - test ? null : 14, - test ? null : 15, - test ? null : 16, - test ? null : 17, - test ? null : 18, - test ? null : 19, - test ? null : 20, - test ? null : 21, - test ? null : 22, - test ? null : 23, - test ? null : 24, - test ? null : 25, - test ? null : 26, - test ? null : 27, - test ? null : 28, - test ? null : 29, - test ? null : 30, - test ? null : 31, - test ? null : 32, - test ? null : 33, - test ? null : 34, - test ? null : 35, - test ? null : 36, - test ? - test ? 1 : 2 : 3 - ); - } -} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/java/codeInspection/DataFlowInspectionTest.java b/java/java-tests/testSrc/com/intellij/java/codeInspection/DataFlowInspectionTest.java index 1585e63e4ed4..87abe72cbc93 100644 --- a/java/java-tests/testSrc/com/intellij/java/codeInspection/DataFlowInspectionTest.java +++ b/java/java-tests/testSrc/com/intellij/java/codeInspection/DataFlowInspectionTest.java @@ -546,5 +546,4 @@ public class DataFlowInspectionTest extends DataFlowInspectionTestCase { public void testGetterOfNullableFieldIsNotAnnotated() { doTest(); } public void testGetterOfNullableFieldIsNotNull() { doTest(); } - public void testUnresolvedInTernary() { doTest(); } }