From 8fdf37e038a20bf3efb96be53f8cd39509e581a3 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Tue, 16 Feb 2016 17:24:42 +0100 Subject: [PATCH] inference: skip unchecked warning for types based on inference variables (IDEA-151761) --- .../constraints/TypeCompatibilityConstraint.java | 2 +- ...UncheckedWarningConvertingToInferenceVariable.java | 11 +++++++++++ .../daemon/lambda/GraphInferenceHighlightingTest.java | 4 ++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/UncheckedWarningConvertingToInferenceVariable.java diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/TypeCompatibilityConstraint.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/TypeCompatibilityConstraint.java index f86c78c2726a..368431f65696 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/TypeCompatibilityConstraint.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/TypeCompatibilityConstraint.java @@ -75,7 +75,7 @@ public class TypeCompatibilityConstraint implements ConstraintFormula { final PsiClassType.ClassResolveResult sResult = ((PsiClassType)s).resolveGenerics(); final PsiClass tClass = tResult.getElement(); final PsiClass sClass = sResult.getElement(); - if (tClass != null && sClass != null) { + if (tClass != null && sClass != null && !(sClass instanceof InferenceVariable)) { final PsiSubstitutor sSubstitutor = TypeConversionUtil.getClassSubstitutor(tClass, sClass, sResult.getSubstitutor()); if (sSubstitutor != null) { if (PsiUtil.isRawSubstitutor(tClass, sSubstitutor)) { diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/UncheckedWarningConvertingToInferenceVariable.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/UncheckedWarningConvertingToInferenceVariable.java new file mode 100644 index 000000000000..9f8d7029043a --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/UncheckedWarningConvertingToInferenceVariable.java @@ -0,0 +1,11 @@ +import java.util.List; + +class Test { + void m(Class clazz){ + List data = foo(clazz); + } + + public static T foo(Class clazz) { + return null; + } +} \ No newline at end of file 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 9544b9e6ed87..e71ad2e341ee 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 @@ -379,6 +379,10 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase doTest(); } + public void testUncheckedWarningConvertingToInferenceVariable() throws Exception { + doTest(); + } + private void doTest() throws Exception { doTest(false); }