Skip to content

Annotate computeIfPresent and compute more like the Checker Framework and Kotlin do. - #32

Merged
wmdietl merged 1 commit into
mainfrom
okcompute
Aug 21, 2023
Merged

wmdietl merged 1 commit into
mainfrom
okcompute

Conversation

@cpovirk

@cpovirk cpovirk commented Aug 15, 2023

Copy link
Copy Markdown
Collaborator

In contrast, for computeIfAbsent, I've kept the signature without
@Nullable on the function result type and method return type. This is
far more convenient for most callers, and it just might not cause
problems for anyone: Callers of computeIfAbsent might always provide
a function that elects to insert a value (as expressed by returning a
non-null value).

I think this gives us the signatures that we'll want for the long term
for Map, though of course we'd revisit if we chose to include
@PolyNull.

Previously:

Note that this PR excludes java.util.Properties because there are a
number of other changes that I'm going to make to it (and then
upstream).

…work and Kotlin do.

In contrast, for _`computeIfAbsent`_, I've kept the signature _without_
`@Nullable` on the function result type and method return type. This is
far more convenient for most callers, and it just might not cause
problems for anyone: Callers of `computeIfAbsent` might _always_ provide
a function that elects to insert a value (as expressed by returning a
non-null value).

I think this gives us the signatures that we'll want for the long term
for `Map`, though of course we'd revisit if we chose to include
`@PolyNull`.

Previously:

- #14 (comment)
- #19 (comment)

Note that this PR excludes `java.util.Properties` because there are a
number of other changes that I'm going to make to it (and then
upstream).
cpovirk added a commit that referenced this pull request Aug 15, 2023
I found my way to those classes as part of
#32, but then I found other things
that looked wrong, even though the classes are annotated with
`@NullMarked.`

@wmdietl wmdietl left a comment

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.

Thanks, looks consistent to me.

@wmdietl
wmdietl merged commit 44eeb5f into main Aug 21, 2023
@wmdietl
wmdietl deleted the okcompute branch August 21, 2023 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants