diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DfaPsiUtil.java b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DfaPsiUtil.java
index ea771598b218..844bcdd86b20 100644
--- a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DfaPsiUtil.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/DfaPsiUtil.java
@@ -104,7 +104,7 @@ public class DfaPsiUtil {
}
if (owner instanceof PsiMethod && isMapMethodWithUnknownNullity((PsiMethod)owner)) {
- return Nullability.UNKNOWN;
+ return getTypeNullability(resultType) == Nullability.NULLABLE ? Nullability.NULLABLE : Nullability.UNKNOWN;
}
Nullability fromType = getTypeNullability(resultType);
diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/MapGetWithNotNullKeys.java b/java/java-tests/testData/inspection/dataFlow/fixture/MapGetWithValueNullability.java
similarity index 65%
rename from java/java-tests/testData/inspection/dataFlow/fixture/MapGetWithNotNullKeys.java
rename to java/java-tests/testData/inspection/dataFlow/fixture/MapGetWithValueNullability.java
index 44ed68952ae2..98c1f62f48f8 100644
--- a/java/java-tests/testData/inspection/dataFlow/fixture/MapGetWithNotNullKeys.java
+++ b/java/java-tests/testData/inspection/dataFlow/fixture/MapGetWithValueNullability.java
@@ -8,6 +8,7 @@ class Test {
if (value == null) {
System.out.println("it's not contained");
}
+ map.get("z").intValue();
value = hashMap.get("y");
if (value == null) {
@@ -15,6 +16,11 @@ class Test {
}
}
+ public void main1(Map<@NotNull String, @Nullable Integer> map, HashMap<@NotNull String, @Nullable Integer> hashMap) {
+ map.get("y").intValue();
+ hashMap.get("y").intValue();
+ }
+
public void main2(Map<@NotNull String, @NotNull Integer> map, HashMap<@NotNull String, @NotNull Integer> hashMap) {
Integer value = map.remove("y");
if (value == null) {
diff --git a/java/java-tests/testSrc/com/intellij/java/codeInspection/DataFlowInspection8Test.java b/java/java-tests/testSrc/com/intellij/java/codeInspection/DataFlowInspection8Test.java
index f64d1e892354..94ca0ab68e25 100644
--- a/java/java-tests/testSrc/com/intellij/java/codeInspection/DataFlowInspection8Test.java
+++ b/java/java-tests/testSrc/com/intellij/java/codeInspection/DataFlowInspection8Test.java
@@ -197,7 +197,7 @@ public class DataFlowInspection8Test extends DataFlowInspectionTestCase {
public void testStreamCustomSumMethod() { doTest(); }
public void testStreamReduceLogicalAnd() { doTest(); }
- public void testMapGetWithNotNullKeys() { doTestWithCustomAnnotations(); }
+ public void testMapGetWithValueNullability() { doTestWithCustomAnnotations(); }
public void testInferNestedForeachNullability() { doTestWithCustomAnnotations(); }
public void testMethodVsExpressionTypeAnnotationConflict() {