Update signature of Map.computeIfAbsent - #156
Conversation
|
That is all true, yet this has been the only(?) case in which I've been holding out hope that we can declare the signature as more restrictive than it really "should" be, just because a |
|
Ah...bummer. We could change the type of We have an open issue (uber/NullAway#1616) on adding some kind of ad hoc |
|
@cpovirk I am curious, it seems that |
|
I agree that there is at most a difference in degree between the two, not a difference in kind. I do somewhat expect that we're going to need to eventually relent on Anyway, to actually answer your question:
Additionally, there are some slight practical differences between the two methods:
|
|
Super helpful, thanks @cpovirk! FWIW the |
mappingFunctionis allowed to returnnullto avoid updating the mapping, and in this case,computeIfAbsentreturnsnull. Also updated overrides in@NullMarkedclasses.I added the
@PolyNullcomment onMap.computeIfAbsentsince I think we'd use it here if it were available; didn't add the comment on all the overrides.Discovered in ben-manes/caffeine#2004 (comment)