From 88c7770258012890181e82c806118d5566ebf0a8 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Mon, 27 Jan 2014 18:25:21 +0400 Subject: [PATCH] graph inference: accept raw inference when return type was erased (IDEA-119844) --- .../resolve/graphInference/InferenceSession.java | 3 +++ .../graphInference/ErasedByReturnConstraint.java | 16 ++++++++++++++++ .../lambda/GraphInferenceHighlightingTest.java | 4 ++++ 3 files changed, 23 insertions(+) create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/ErasedByReturnConstraint.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 aea49218495c..037f88847d2a 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 @@ -312,6 +312,9 @@ public class InferenceSession { }); } if (targetType != null) { + if (targetType instanceof PsiClassType && ((PsiClassType)targetType).isRaw()) { + setErased(); + } myConstraints.add(new TypeCompatibilityConstraint(myErased ? TypeConversionUtil.erasure(targetType) : GenericsUtil.eliminateWildcards(targetType, false), PsiImplUtil.normalizeWildcardTypeByPosition(returnType, context))); } } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/ErasedByReturnConstraint.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/ErasedByReturnConstraint.java new file mode 100644 index 000000000000..47940ac81435 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/ErasedByReturnConstraint.java @@ -0,0 +1,16 @@ +import java.util.List; + +public class Bug +{ + + void foo(List futures, I1 callable){ + futures.add(submit(callable)); + } + + I submit(I1 task){ + return null; + } + + interface I{} + interface I1{} +} 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 d0048b7f962f..1e4418b75c3b 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 @@ -108,6 +108,10 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase doTest(); } + public void testErasedByReturnConstraint() throws Exception { + doTest(); + } + private void doTest() throws Exception { doTest(false); }