diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceVariable.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceVariable.java index a490643cf8bf..88778eff3e45 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceVariable.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceVariable.java @@ -19,6 +19,7 @@ import com.intellij.psi.*; import com.intellij.psi.impl.light.LightTypeParameter; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.PsiUtil; +import com.intellij.psi.util.TypeConversionUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -44,6 +45,7 @@ public class InferenceVariable extends LightTypeParameter { super(parameter); myName = name; myContext = context; + TypeConversionUtil.markAsFreshVariable(this, context); } public PsiType getInstantiation() { diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57494.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57494.java index 38bafca27f55..c52216cfd7de 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57494.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/IDEA57494.java @@ -11,6 +11,6 @@ abstract class A1{ abstract T baz(List a); void bar(List x){ - String o = baz(x); + String o = baz(x); } } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/InferenceVariablesErasure.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/InferenceVariablesErasure.java new file mode 100644 index 000000000000..a500d1e834af --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/InferenceVariablesErasure.java @@ -0,0 +1,21 @@ +interface E {} +interface F extends E { + ArrayFactory ARRAY_FACTORY = null; +} + +interface ArrayFactory { + T[] create(int count); +} + +interface Stub {} + +class M { + + public F[] get(Stub s) { + return foo(s, F.ARRAY_FACTORY); + } + + private T[] foo(Stub stub, ArrayFactory arrayFactory) { + 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 1ac990d85b1c..9544b9e6ed87 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 @@ -375,6 +375,10 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase doTest(); } + public void testInferenceVariablesErasure() throws Exception { + doTest(); + } + private void doTest() throws Exception { doTest(false); }