From adaa0f09b7278ac3210efebc2a5b6680284228ce Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Mon, 28 Dec 2015 17:31:41 +0100 Subject: [PATCH] new inference: pull erased flag through nested calls (IDEA-133613) --- .../graphInference/InferenceSession.java | 4 ++++ .../ExpressionCompatibilityConstraint.java | 13 +++++++++-- ...heckedWarningNotionThroughNestedCalls.java | 22 +++++++++++++++++++ .../GraphInferenceHighlightingTest.java | 4 ++++ 4 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/PullUncheckedWarningNotionThroughNestedCalls.java diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java index a748d3aacd3e..637154939948 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java @@ -1810,4 +1810,8 @@ public class InferenceSession { public List getIncompatibleErrorMessages() { return myErrorMessages; } + + public boolean isErased() { + return myErased; + } } diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/ExpressionCompatibilityConstraint.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/ExpressionCompatibilityConstraint.java index e835006ec171..b41c9b682873 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/ExpressionCompatibilityConstraint.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/ExpressionCompatibilityConstraint.java @@ -56,8 +56,14 @@ public class ExpressionCompatibilityConstraint extends InputOutputConstraintForm return false; } - if (exprType instanceof PsiClassType && ((PsiClassType)exprType).resolve() == null) { - return true; + if (exprType instanceof PsiClassType) { + if (((PsiClassType)exprType).resolve() == null) { + return true; + } + + if (((PsiClassType)exprType).isRaw()) { + session.setErased(); + } } if (exprType != null && exprType != PsiType.NULL) { @@ -94,6 +100,9 @@ public class ExpressionCompatibilityConstraint extends InputOutputConstraintForm if (callSession != session) { session.getInferenceSessionContainer().registerNestedSession(callSession); session.propagateVariables(callSession.getInferenceVariables()); + if (callSession.isErased()) { + session.setErased(); + } } return true; } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/PullUncheckedWarningNotionThroughNestedCalls.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/PullUncheckedWarningNotionThroughNestedCalls.java new file mode 100644 index 000000000000..b2f49981a245 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/PullUncheckedWarningNotionThroughNestedCalls.java @@ -0,0 +1,22 @@ +import java.util.List; + +class Temp { + + public static List foo() { + return parallelizePairs(asList(new Tuple())).partitionBy(); + } + + public static List asList(T a) { + return null; + } + + public static Temp parallelizePairs(List> list) { + return null; + } + + public List partitionBy() { return null; } +} + +class Tuple { + public Tuple() {} +} diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GraphInferenceHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GraphInferenceHighlightingTest.java index a2705496f2b7..5b6a9741a14d 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GraphInferenceHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/GraphInferenceHighlightingTest.java @@ -351,6 +351,10 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase doTest(); } + public void testPullUncheckedWarningNotionThroughNestedCalls() throws Exception { + doTest(); + } + private void doTest() throws Exception { doTest(false); }