diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceIncorporationPhase.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceIncorporationPhase.java index 11b8fefb06d2..b60a12e04e65 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceIncorporationPhase.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceIncorporationPhase.java @@ -265,9 +265,17 @@ public class InferenceIncorporationPhase { */ private void upDown(List eqBounds, List upperBounds, PsiSubstitutor substitutor) { for (PsiType upperBound : upperBounds) { - if (upperBound == null || PsiType.NULL.equals(upperBound)) continue; + if (upperBound == null || PsiType.NULL.equals(upperBound) || upperBound instanceof PsiWildcardType) continue; + + if (upperBound instanceof PsiCapturedWildcardType) { + upperBound = ((PsiCapturedWildcardType)upperBound).getUpperBound(); + } + for (PsiType eqBound : eqBounds) { - if (eqBound == null || PsiType.NULL.equals(eqBound)) continue; + if (eqBound == null || PsiType.NULL.equals(eqBound) || eqBound instanceof PsiWildcardType) continue; + if (eqBound instanceof PsiCapturedWildcardType) { + eqBound = ((PsiCapturedWildcardType)eqBound).getUpperBound(); + } addConstraint(new StrictSubtypingConstraint(substitutor.substitute(upperBound), substitutor.substitute(eqBound))); } } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/IncorporationOfBoundsAsTypeArguments.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/IncorporationOfBoundsAsTypeArguments.java new file mode 100644 index 000000000000..b55a7b9805ed --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/IncorporationOfBoundsAsTypeArguments.java @@ -0,0 +1,20 @@ + +import java.util.*; + +class Test { + public static void main(String[] args) { + Factory factory = new Factory(); + final Class bClass = null; + ClassB b = factory.create(bClass); + String str = factory.create(bClass); + } + + public static class Factory { + , I extends List> T create(Class pClassA) { + return null; + } + } + + interface ClassA> {} + interface ClassB extends ClassA> {} +} \ 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 01ef24e8630f..580cae3595d9 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 @@ -327,6 +327,10 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase doTest(); } + public void testIncorporationOfBoundsAsTypeArguments() throws Exception { + doTest(); + } + private void doTest() throws Exception { doTest(false); }