mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-174964 Incorrect null analysis of NavigableSet<@NotNull T>
This commit is contained in:
@@ -70,10 +70,9 @@ public class DfaPsiUtil {
|
||||
|
||||
@NotNull
|
||||
public static Nullness getElementNullability(@Nullable PsiType resultType, @Nullable PsiModifierListOwner owner) {
|
||||
Nullness x = getTypeNullability(resultType);
|
||||
if (x != Nullness.UNKNOWN) return x;
|
||||
if (owner == null) return getTypeNullability(resultType);
|
||||
|
||||
if (owner == null || resultType instanceof PsiPrimitiveType) {
|
||||
if (resultType instanceof PsiPrimitiveType) {
|
||||
return Nullness.UNKNOWN;
|
||||
}
|
||||
|
||||
@@ -91,6 +90,9 @@ public class DfaPsiUtil {
|
||||
return Nullness.NOT_NULL;
|
||||
}
|
||||
|
||||
Nullness fromType = getTypeNullability(resultType);
|
||||
if (fromType != Nullness.UNKNOWN) return fromType;
|
||||
|
||||
if (PsiJavaPatterns.psiParameter().withParents(PsiParameterList.class, PsiLambdaExpression.class).accepts(owner)) {
|
||||
PsiLambdaExpression lambda = (PsiLambdaExpression)owner.getParent().getParent();
|
||||
int index = lambda.getParameterList().getParameterIndex((PsiParameter)owner);
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
import withTypeUse.NotNull;
|
||||
import withTypeUse.Nullable;
|
||||
import java.util.NavigableSet;
|
||||
|
||||
interface Foo<T> {
|
||||
@Nullable T get();
|
||||
T get2();
|
||||
}
|
||||
|
||||
class Bar {
|
||||
|
||||
public void test(Foo<@NotNull String> f, NavigableSet<@NotNull String> set) {
|
||||
if (f.get() == null) return;
|
||||
if (<warning descr="Condition 'f.get2() == null' is always 'false'">f.get2() == null</warning>) return;
|
||||
if (set.pollFirst() == null) return;
|
||||
}
|
||||
}
|
||||
@@ -160,4 +160,9 @@ public class DataFlowInspection8Test extends DataFlowInspectionTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testMethodVsExpressionTypeAnnotationConflict() {
|
||||
setupCustomAnnotations("withTypeUse", "{ElementType.METHOD, ElementType.TYPE_USE}", myFixture);
|
||||
doTest();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1082,9 +1082,30 @@
|
||||
<item name="java.util.Map void putAll(java.util.Map<? extends K,? extends V>) 0">
|
||||
<annotation name="org.jetbrains.annotations.NotNull" />
|
||||
</item>
|
||||
<item name='java.util.NavigableSet E ceiling(E)'>
|
||||
<annotation name='org.jetbrains.annotations.Nullable'/>
|
||||
</item>
|
||||
<item name='java.util.NavigableSet E floor(E)'>
|
||||
<annotation name='org.jetbrains.annotations.Nullable'/>
|
||||
</item>
|
||||
<item name='java.util.NavigableSet E higher(E)'>
|
||||
<annotation name='org.jetbrains.annotations.Nullable'/>
|
||||
</item>
|
||||
<item name='java.util.NavigableSet E lower(E)'>
|
||||
<annotation name='org.jetbrains.annotations.Nullable'/>
|
||||
</item>
|
||||
<item name='java.util.NavigableSet E pollFirst()'>
|
||||
<annotation name='org.jetbrains.annotations.Nullable'/>
|
||||
</item>
|
||||
<item name='java.util.NavigableSet E pollLast()'>
|
||||
<annotation name='org.jetbrains.annotations.Nullable'/>
|
||||
</item>
|
||||
<item name="java.util.NavigableSet java.util.Iterator<E> descendingIterator()">
|
||||
<annotation name="org.jetbrains.annotations.NotNull" />
|
||||
</item>
|
||||
<item name='java.util.NavigableSet java.util.Iterator<E> iterator()'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name="java.util.NavigableSet java.util.NavigableSet<E> descendingSet()">
|
||||
<annotation name="org.jetbrains.annotations.NotNull" />
|
||||
</item>
|
||||
@@ -1097,6 +1118,15 @@
|
||||
<item name="java.util.NavigableSet java.util.NavigableSet<E> tailSet(E, boolean)">
|
||||
<annotation name="org.jetbrains.annotations.NotNull" />
|
||||
</item>
|
||||
<item name='java.util.NavigableSet java.util.SortedSet<E> headSet(E)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name='java.util.NavigableSet java.util.SortedSet<E> subSet(E, E)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name='java.util.NavigableSet java.util.SortedSet<E> tailSet(E)'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name='java.util.Objects T requireNonNull(T)'>
|
||||
<annotation name='org.jetbrains.annotations.Contract'>
|
||||
<val name="value" val=""null->fail""/>
|
||||
|
||||
Reference in New Issue
Block a user