mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java] [inference] ease conflict detection in intersection types (IDEA-289929)
GitOrigin-RevId: aee88647f315474c421c31512f5edad3a4d07dfd
This commit is contained in:
committed by
intellij-monorepo-bot
parent
e2c116950b
commit
92c59dacba
+4
-3
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
final class Mapping { }
|
||||
|
||||
class Main {
|
||||
|
||||
public <A extends Mapping> List<A> n(Predicate<? super A> filter) {
|
||||
return m(filter);
|
||||
}
|
||||
|
||||
private <B extends Mapping> List<B> m( Predicate<? super B> filter) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
+2
-1
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user