Files
openide/java/java-tests/testData/inspection/nullableProblems/PassingNullableMapValueWhereNotNullIsExpected.java
Georgii Ustinovandintellij-monorepo-bot 5480b565a5 [Java. Inspections] IDEA-375132 Nullable return incompatibilities Basic implementation.
MR brings detection of nullable inconsistencies inside return expressions for generic types. Now it supports
- Support of arbitrary generic type (previously only collections was supported)
- Recursive detection of inconsistencies
- Detection of assigning not-null to nullable (via option)

GitOrigin-RevId: ed37ea02ca44db58698f36f2ca82c67171733e69
2025-10-02 14:36:35 +00:00

14 lines
511 B
Java

import typeUse.*;
import java.util.*;
class Test {
public @NotNull Map<@NotNull String, @NotNull ArrayList<@NotNull String>> getDataBroken() {
ArrayList<@Nullable String> arrayList = new ArrayList<>();
arrayList.add(null);
@NotNull Map<@NotNull String, @NotNull ArrayList<@Nullable String>> map = new HashMap<>();
map.put("x", arrayList);
return <warning descr="Returning a class with nullable type parameters when a class with non-null type parameters is expected">map</warning>;
}
}