mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
check that inferred intersection type doesn't contain same generic type with different type arguments (IDEA-170325)
This commit is contained in:
+7
-1
@@ -1265,7 +1265,13 @@ public class InferenceSession {
|
||||
}
|
||||
|
||||
if (type instanceof PsiIntersectionType) {
|
||||
final String conflictingConjunctsMessage = ((PsiIntersectionType)type).getConflictingConjunctsMessage();
|
||||
String conflictingConjunctsMessage = ((PsiIntersectionType)type).getConflictingConjunctsMessage();
|
||||
if (conflictingConjunctsMessage == null) {
|
||||
if (findParameterizationOfTheSameGenericClass(var.getBounds(InferenceBound.UPPER), pair -> pair.first == null || pair.second == null || pair.first.equals(pair.second)) != null) {
|
||||
//warn if upper bounds has same generic class with different type arguments
|
||||
conflictingConjunctsMessage = type.getPresentableText(false);
|
||||
}
|
||||
}
|
||||
if (conflictingConjunctsMessage != null) {
|
||||
registerIncompatibleErrorMessage("Type parameter " + var.getParameter().getName() + " has incompatible upper bounds: " + conflictingConjunctsMessage);
|
||||
return PsiType.NULL;
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
class A {
|
||||
|
||||
void m(final Stream<String> stream){
|
||||
Set<String> ALLOWED_PROPS = unmodifiableSet <error descr="'unmodifiableSet(java.util.Set<? extends java.lang.String>)' in 'A' cannot be applied to '(java.util.HashSet<java.lang.String>)'">(stream.collect(Collectors.toCollection(HashSet::new)))</error>;
|
||||
}
|
||||
|
||||
public static <T1> Set<T1> unmodifiableSet(Set<? extends T1> s) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+4
@@ -174,6 +174,10 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
|
||||
//public void _testAssignabilityOfStandaloneExpressionsDuringApplicabilityCheck() { doTest(); }
|
||||
public void testRecursiveTypeWithCapture() { doTest(); }
|
||||
|
||||
public void testApplicabilityCheckFailsExpressionTypeCheckPasses() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user