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); }