diff --git a/java/java-psi-api/src/com/intellij/psi/PsiCapturedWildcardType.java b/java/java-psi-api/src/com/intellij/psi/PsiCapturedWildcardType.java index bf3b6a65e519..e3416e934584 100644 --- a/java/java-psi-api/src/com/intellij/psi/PsiCapturedWildcardType.java +++ b/java/java-psi-api/src/com/intellij/psi/PsiCapturedWildcardType.java @@ -16,7 +16,6 @@ package com.intellij.psi; import com.intellij.openapi.util.Comparing; -import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.RecursionGuard; import com.intellij.openapi.util.RecursionManager; import com.intellij.psi.search.GlobalSearchScope; @@ -83,13 +82,17 @@ public class PsiCapturedWildcardType extends PsiType.Stub { glb = substitutedBoundType; } else { - glb = GenericsUtil.getGreatestLowerBound(glb, substitutedBoundType); + glb = getGreatestLowerBound(glb, substitutedBoundType, wildcardType); } } return glb; } + private static PsiType getGreatestLowerBound(PsiType glb, PsiType bound, Object guardObject) { + return guard.doPreventingRecursion(guardObject, true, () -> GenericsUtil.getGreatestLowerBound(glb, bound)); + } + @Override public boolean equals(Object o) { if (!(o instanceof PsiCapturedWildcardType)) { diff --git a/java/java-psi-api/src/com/intellij/psi/PsiIntersectionType.java b/java/java-psi-api/src/com/intellij/psi/PsiIntersectionType.java index 4bd643b13974..331063c585dd 100644 --- a/java/java-psi-api/src/com/intellij/psi/PsiIntersectionType.java +++ b/java/java-psi-api/src/com/intellij/psi/PsiIntersectionType.java @@ -60,7 +60,7 @@ public class PsiIntersectionType extends PsiType.Stub { @NotNull private static PsiType[] flattenAndRemoveDuplicates(@NotNull PsiType[] conjuncts) { try { - final Set flattenConjuncts = PsiCapturedWildcardType.guard.doPreventingRecursion(conjuncts, true, () -> flatten(conjuncts, ContainerUtil.newLinkedHashSet())); + final Set flattenConjuncts = flatten(conjuncts, ContainerUtil.newLinkedHashSet()); if (flattenConjuncts == null) { return conjuncts; } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/ValidIntersectionTypeWithCapturedBounds1.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/ValidIntersectionTypeWithCapturedBounds1.java new file mode 100644 index 000000000000..bba01422feca --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/ValidIntersectionTypeWithCapturedBounds1.java @@ -0,0 +1,21 @@ + +abstract class Bug { + void m1(){ + D jobHandler = m(); + } + + abstract > J m(); +} + +interface B { +} + +abstract class C { + +} + +abstract class D extends C { + +} + +abstract class E implements B { } \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/lambda/GraphInferenceHighlightingTest.java b/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/lambda/GraphInferenceHighlightingTest.java index 2aad6e703571..fd044c5a5e0e 100644 --- a/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/lambda/GraphInferenceHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/java/codeInsight/daemon/lambda/GraphInferenceHighlightingTest.java @@ -116,6 +116,7 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase public void testIDEA149774() { doTest(); } public void testDisjunctionTypes() { doTest(); } public void testValidIntersectionTypeWithCapturedBounds() { doTest(); } + public void testValidIntersectionTypeWithCapturedBounds1() { doTest(); } public void testPushErasedStateToArguments() { doTest(); } public void testStopAtStandaloneConditional() { doTest(); } public void testTransitiveInferenceVariableDependencies() { doTest(); }