Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1618,6 +1618,7 @@ public void compareGenericTypeParameterNullabilityForCall(
}
}
});
maybeStorePolyExpressionTypeFromTarget(currentActualParam, formalParameter);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -537,15 +537,24 @@ interface Consumer<T extends @Nullable Object> {
static @Nullable String mapToNull(String s) {
return null;
}
static String id(String s) { return s; }
static void callHashCode(Object o) { o.hashCode(); }
static void test(List<String> list) {
static void doNothing(@Nullable Object o) {}
static void testPositive(List<String> list) {
list.stream().map(Test::mapToNull).forEach(s -> {
// BUG: Diagnostic contains: dereferenced expression s is @Nullable
s.hashCode();
});
// TODO we should report an error here (https://github.com/uber/NullAway/issues/1552)
// BUG: Diagnostic contains: parameter o of referenced method is @NonNull, but parameter in functional interface method Test.Consumer.accept(T) is @Nullable
list.stream().map(Test::mapToNull).forEach(Test::callHashCode);
}
static void testNegative(List<String> list) {
list.stream().map(Test::mapToNull).forEach(s -> {
if (s != null) { s.hashCode(); }
});
list.stream().map(Test::mapToNull).forEach(Test::doNothing);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably also worth checking that, without the map to null, a Stream<String> works just fine with .forEach(Test::callHashCode);, no?

list.stream().map(Test::id).forEach(Test::callHashCode);
}
}""")
.doTest();
}
Expand Down
Loading