diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java
index 51c710ad2bd8..b435837bc407 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java
@@ -1,4 +1,4 @@
-// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
+// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.psi.impl.source.resolve.graphInference;
import com.intellij.core.JavaPsiBundle;
@@ -1255,9 +1255,10 @@ public class InferenceSession {
PsiClass oppositeConjunct = PsiUtil.resolveClassInClassTypeOnly(conjuncts[i1]);
if (conjunct == null || oppositeConjunct == null) {
if (conjuncts[i] instanceof PsiArrayType &&
- TypesDistinctProver.proveArrayTypeDistinct((PsiArrayType)conjuncts[i], conjuncts[i1]) ||
+ TypesDistinctProver.proveArrayTypeDistinct((PsiArrayType)conjuncts[i], conjuncts[i1]) ||
conjuncts[i] instanceof PsiCapturedWildcardType &&
- oppositeConjunct != null && !oppositeConjunct.isInterface() && !(oppositeConjunct instanceof PsiTypeParameter)) {
+ oppositeConjunct != null && !oppositeConjunct.isInterface() && !(oppositeConjunct instanceof PsiTypeParameter) &&
+ !(((PsiCapturedWildcardType)conjuncts[i]).getWildcard().isSuper() && TypeConversionUtil.isAssignable(conjuncts[i1], ((PsiCapturedWildcardType)conjuncts[i]).getLowerBound()))) {
return JavaPsiBundle.message("conflicting.conjuncts", conjuncts[i].getPresentableText(), conjuncts[i1].getPresentableText());
}
}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/IntersectionWithCapturedSuperWildcard.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/IntersectionWithCapturedSuperWildcard.java
new file mode 100644
index 000000000000..4461e25d3d7e
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/graphInference/IntersectionWithCapturedSuperWildcard.java
@@ -0,0 +1,16 @@
+import java.util.List;
+import java.util.function.Predicate;
+
+final class Mapping { }
+
+class Main {
+
+ public List n(Predicate super A> filter) {
+ return m(filter);
+ }
+
+ private List m( Predicate super B> filter) {
+ return null;
+ }
+
+}
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 1b92062ff414..a615d19c40a1 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
@@ -1,4 +1,4 @@
-// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
+// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.java.codeInsight.daemon.lambda;
import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase;
@@ -194,6 +194,7 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
public void testTopLevelParentNoParameters() { doTest(); }
public void testRawTypeOnTheRight() { doTest(); }
public void testMutualBoundPromotion() { doTest(); }
+ public void testIntersectionWithCapturedSuperWildcard() { doTest(); }
private void doTest() {
doTest(false);