Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve nullness of types in some APIs related to Map merging, and fix Collectors.toMap null-handling. #7058

Closed
wants to merge 0 commits into from

Conversation

copybara-service[bot]
Copy link
Contributor

@copybara-service copybara-service bot commented Feb 28, 2024

Improve nullness of types in some APIs related to Map merging, and fix Collectors.toMap null-handling.

  • Restrict Collections.toMap value-type arguments to non-nullable types.
  • Fix Collections.toMap to remove the key in question when mergeFunction returns null.
    • ...in J2KT
    • ...in J2CL
  • Use @NonNull / & Any in a few places in Map.merge and Map.computeIfPresent.
    • ...in J2KT
    • ...in Guava Map implementations, even though we don't yet include @NonNull annotations in the JDK APIs that we build Guava against. (See post-submit discussion on cl/559605577. But I've taken the shortcut of not waiting for the JDK APIs.)
  • Use @Nullable (to match the existing Kotlin ? types) in the return types of Map.computeIfPresent and Map.compute.
    • ...in J2KT
  • Test a bunch of this.

Note that the test for mergeFunction has to work around an overly restricted toMap signature that J2KT inherited from JSpecify. As discussed in a code comment there, this is fundamentally the same issue as we have in Guava with ImmutableMap.toImmutableMap, which is discussed as part of #6824.

RELNOTES=n/a

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.

0 participants