mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
hardcode Map.remove as having unknown nullity (IDEA-CR-28277, IDEA-183875)
This commit is contained in:
@@ -106,7 +106,7 @@ public class DfaPsiUtil {
|
||||
return Nullness.NOT_NULL;
|
||||
}
|
||||
|
||||
if (owner instanceof PsiMethod && isMapGet((PsiMethod)owner)) {
|
||||
if (owner instanceof PsiMethod && isMapMethodWithUnknownNullity((PsiMethod)owner)) {
|
||||
return Nullness.UNKNOWN;
|
||||
}
|
||||
|
||||
@@ -127,10 +127,11 @@ public class DfaPsiUtil {
|
||||
return Nullness.UNKNOWN;
|
||||
}
|
||||
|
||||
private static boolean isMapGet(@NotNull PsiMethod method) {
|
||||
if (!"get".equals(method.getName())) return false;
|
||||
private static boolean isMapMethodWithUnknownNullity(@NotNull PsiMethod method) {
|
||||
String name = method.getName();
|
||||
if (!"get".equals(name) && !"remove".equals(name)) return false;
|
||||
PsiMethod superMethod = DeepestSuperMethodsSearch.search(method).findFirst();
|
||||
return "java.util.Map.get".equals(PsiUtil.getMemberQualifiedName(superMethod != null ? superMethod : method));
|
||||
return ("java.util.Map." + name).equals(PsiUtil.getMemberQualifiedName(superMethod != null ? superMethod : method));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -14,4 +14,16 @@ class Test {
|
||||
System.out.println("it's not contained");
|
||||
}
|
||||
}
|
||||
|
||||
public void main2(Map<@NotNull String, @NotNull Integer> map, HashMap<@NotNull String, @NotNull Integer> hashMap) {
|
||||
Integer value = map.remove("y");
|
||||
if (value == null) {
|
||||
System.out.println("it's not contained");
|
||||
}
|
||||
|
||||
value = hashMap.remove("y");
|
||||
if (value == null) {
|
||||
System.out.println("it's not contained");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1646,7 +1646,6 @@
|
||||
<val name="source" val=""this.values""/>
|
||||
<val name="sourceIsContainer" val="true" />
|
||||
</annotation>
|
||||
<annotation name='org.jetbrains.annotations.Nullable'/>
|
||||
</item>
|
||||
<item name='java.util.Map V replace(K, V)'>
|
||||
<annotation name='org.jetbrains.annotations.Contract'>
|
||||
|
||||
Reference in New Issue
Block a user