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 02b5f7db242f..79b1c1151bbb 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 @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -51,6 +51,9 @@ public class ExpressionCompatibilityConstraint extends InputOutputConstraintForm final PsiType type = myExpression.getType(); session.registerIncompatibleErrorMessage((type != null ? type.getPresentableText() : myExpression.getText()) + " is not compatible with " + session.getPresentableText(myT)); } + else if (TypeCompatibilityConstraint.isUncheckedConversion(myT, exprType)) { + session.setErasedDuringApplicabilityCheck(); + } return assignmentCompatible; } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/UncheckedConversionDuringProperTypeExpressionConstraintResolution.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/UncheckedConversionDuringProperTypeExpressionConstraintResolution.java new file mode 100644 index 000000000000..4d85bb7bce2a --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/UncheckedConversionDuringProperTypeExpressionConstraintResolution.java @@ -0,0 +1,17 @@ +class Test { + private static AG foo(Class clz) { + return (AG) foo1(clz); + } + + private static G foo1(Class clz) { + return null; + } + + interface E {} + interface AE extends E {} + + interface G {} + interface AG extends G {} + +} + 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 b402caf50635..b24ba27285bd 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 @@ -491,6 +491,10 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase doTest(); } + public void testUncheckedConversionDuringProperTypeExpressionConstraintResolution() throws Exception { + doTest(); + } + private void doTest() throws Exception { doTest(false); }