Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Use OptimizedLibraryModels for method type variable upper bounds#1388

Merged
msridhar merged 3 commits intomasterfrom
opt-lib-models-for-upper-bounds
Dec 21, 2025
Merged

Use OptimizedLibraryModels for method type variable upper bounds#1388
msridhar merged 3 commits intomasterfrom
opt-lib-models-for-upper-bounds

Conversation

Copy link
Collaborator

msridhar commented Dec 21, 2025 *
edited by coderabbitai bot
Loading

We missed this optimization when first adding this feature

Summary by CodeRabbit

  • Refactor
    • Improved null-safety analysis: the generic method-type-variable handling now uses additional analysis context, enabling more accurate detection of nullable upper bounds for overridden methods and reducing incorrect diagnostics when validating generic method type arguments.

Tip: You can customize this high-level summary in your review settings.

Copy link
Contributor

coderabbitai bot commented Dec 21, 2025 *
edited
Loading

Walkthrough

The PR changes the signature of onOverrideMethodTypeVariableUpperBound to add a VisitorState parameter across the handlers framework. The signature is updated from (Symbol.MethodSymbol methodSymbol, int typeVarIndex) to (Symbol.MethodSymbol methodSymbol, int typeVarIndex, VisitorState state) in Handler, CompositeHandler, LibraryModelsHandler, and call sites in GenericsChecks and ConstraintSolverImpl are adjusted. LibraryModelsHandler now uses the supplied VisitorState to access optimized library models.

Possibly related PRs

Suggested reviewers

  • lazaroclapp
  • yuxincs

Pre-merge checks and finishing touches

Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 30.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Passed checks (2 passed)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit's high-level summary is enabled.
Title check Passed The title accurately describes the main change: updating method type variable upper bound handling to use OptimizedLibraryModels, which is reflected across all modified files.
Finishing touches
  • Generate docstrings
Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch opt-lib-models-for-upper-bounds

Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Commits

Reviewing files that changed from the base of the PR and between 5f10ca5 and cf8812b.

Files selected for processing (1)
  • nullaway/src/main/java/com/uber/nullaway/handlers/Handler.java (1 hunks)
Additional context used
Learnings (1)
Common learnings Learnt from: msridhar
Repo: uber/NullAway PR: 1248
File: nullaway/src/main/java/com/uber/nullaway/generics/GenericsChecks.java:847-857
Timestamp: 2025-08-28T04:54:20.953Z
Learning: In NullAway's GenericsChecks.java, NewClassTree support for explicit type argument substitution requires more extensive changes beyond just modifying the conditional in compareGenericTypeParameterNullabilityForCall. The maintainers prefer to handle NewClassTree support in a separate follow-up rather than expanding the scope of PRs focused on specific issues like super constructor calls.
Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Build and test on ubuntu-latest
  • GitHub Check: Build and test on macos-latest
  • GitHub Check: Build and test on windows-latest
  • GitHub Check: Build caffeine with snapshot
Additional comments (2)
nullaway/src/main/java/com/uber/nullaway/handlers/Handler.java (2)

457-457: LGTM! Javadoc documentation is now complete.

The previous review concern about missing Javadoc for the state parameter has been addressed. The Javadoc on line 457 properly documents the new parameter, and the documentation style is consistent with other methods in this file.

Also applies to: 461-462


461-462: All Handler implementations and call sites have been properly updated for the interface change.

The interface now provides a default implementation of onOverrideMethodTypeVariableUpperBound that returns false. LibraryModelsHandler and CompositeHandler override this method with the correct signature, while other Handler implementations safely rely on the default behavior. Both call sites in GenericsChecks and ConstraintSolverImpl use the correct method signature. No missed updates detected across the codebase.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai bot reviewed Dec 21, 2025
Copy link
Contributor

coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Commits

Reviewing files that changed from the base of the PR and between 6acbb64 and 5f10ca5.

Files selected for processing (5)
  • nullaway/src/main/java/com/uber/nullaway/generics/ConstraintSolverImpl.java (1 hunks)
  • nullaway/src/main/java/com/uber/nullaway/generics/GenericsChecks.java (1 hunks)
  • nullaway/src/main/java/com/uber/nullaway/handlers/CompositeHandler.java (1 hunks)
  • nullaway/src/main/java/com/uber/nullaway/handlers/Handler.java (1 hunks)
  • nullaway/src/main/java/com/uber/nullaway/handlers/LibraryModelsHandler.java (4 hunks)
Additional context used
Learnings (3)
Common learnings Learnt from: msridhar
Repo: uber/NullAway PR: 1248
File: nullaway/src/main/java/com/uber/nullaway/generics/GenericsChecks.java:847-857
Timestamp: 2025-08-28T04:54:20.953Z
Learning: In NullAway's GenericsChecks.java, NewClassTree support for explicit type argument substitution requires more extensive changes beyond just modifying the conditional in compareGenericTypeParameterNullabilityForCall. The maintainers prefer to handle NewClassTree support in a separate follow-up rather than expanding the scope of PRs focused on specific issues like super constructor calls.
Learning: 2025-08-28T04:54:20.953Z Learnt from: msridhar
Repo: uber/NullAway PR: 1248
File: nullaway/src/main/java/com/uber/nullaway/generics/GenericsChecks.java:847-857
Timestamp: 2025-08-28T04:54:20.953Z
Learning: In NullAway's GenericsChecks.java, NewClassTree support for explicit type argument substitution requires more extensive changes beyond just modifying the conditional in compareGenericTypeParameterNullabilityForCall. The maintainers prefer to handle NewClassTree support in a separate follow-up rather than expanding the scope of PRs focused on specific issues like super constructor calls.

Applied to files:

  • nullaway/src/main/java/com/uber/nullaway/handlers/CompositeHandler.java
  • nullaway/src/main/java/com/uber/nullaway/generics/GenericsChecks.java
  • nullaway/src/main/java/com/uber/nullaway/handlers/LibraryModelsHandler.java
  • nullaway/src/main/java/com/uber/nullaway/generics/ConstraintSolverImpl.java
Learning: 2025-10-29T23:56:18.236Z Learnt from: msridhar
Repo: uber/NullAway PR: 1316
File: jdk-javac-plugin/src/main/java/com/uber/nullaway/javacplugin/NullnessAnnotationSerializer.java:261-293
Timestamp: 2025-10-29T23:56:18.236Z
Learning: In NullAway's jdk-javac-plugin NullnessAnnotationSerializer, type variable bounds with annotations (e.g., `T extends Nullable Object`) are checked at their declaration sites by the typeParamHasAnnotation method for both class-level and method-level type parameters. The hasJSpecifyAnnotationDeep method is designed to check type uses (return types, parameters, etc.) and does not need a TYPEVAR case because type variable declaration bounds are already handled separately.

Applied to files:

  • nullaway/src/main/java/com/uber/nullaway/generics/GenericsChecks.java
  • nullaway/src/main/java/com/uber/nullaway/handlers/LibraryModelsHandler.java
  • nullaway/src/main/java/com/uber/nullaway/generics/ConstraintSolverImpl.java
Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Build and test on windows-latest
  • GitHub Check: Build and test on macos-latest
  • GitHub Check: Build spring-framework with snapshot
  • GitHub Check: Build caffeine with snapshot
  • GitHub Check: Build and test on ubuntu-latest
Additional comments (6)
nullaway/src/main/java/com/uber/nullaway/generics/ConstraintSolverImpl.java (1)

311-314: LGTM!

The call site is correctly updated to pass the state parameter, which is already available as an instance field. This aligns with the updated Handler interface signature.

nullaway/src/main/java/com/uber/nullaway/handlers/LibraryModelsHandler.java (3)

364-370: LGTM! Optimization correctly applied.

The implementation now uses OptimizedLibraryModels for method type variable upper bounds lookup, which provides efficient symbol-based lookup using the NameIndexedMap structure. This is consistent with how other library model lookups are optimized in this handler.


1264-1264: LGTM!

The new field methodTypeVariablesWithNullableUpperBounds and its initialization correctly follow the established pattern for other optimized lookups in OptimizedLibraryModels.

Also applies to: 1279-1281


1319-1322: LGTM!

The new lookup method follows the same pattern as other methods like castToNonNullMethod and failIfNullParameters, correctly delegating to lookupImmutableSet.

nullaway/src/main/java/com/uber/nullaway/generics/GenericsChecks.java (1)

264-266: LGTM!

The call site is correctly updated to pass the state parameter, enabling the optimized library models lookup for method type variable upper bounds.

nullaway/src/main/java/com/uber/nullaway/handlers/CompositeHandler.java (1)

328-338: LGTM!

The composite handler correctly propagates the new state parameter to each handler in the chain, maintaining the existing short-circuit behavior that returns true as soon as any handler signals that the type variable has a nullable upper bound.

Comment on lines 460 to 463
default boolean onOverrideMethodTypeVariableUpperBound(
Symbol.MethodSymbol methodSymbol, int index) {
Symbol.MethodSymbol methodSymbol, int index, VisitorState state) {
return false;
}
Copy link
Contributor

coderabbitai bot Dec 21, 2025

Choose a reason for hiding this comment

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

Nitpick | Trivial

Missing Javadoc for new state parameter.

The @param state documentation is missing from the method's Javadoc comment. Please add documentation for this parameter to maintain consistency with the existing Javadoc.

Proposed Javadoc update

Add the following to the Javadoc block above the method:

* @param methodSymbol The method symbol
* @param index index of the generic type variable (starting at 0)
+ * @param state The current visitor state
* @return boolean true if the variable should be treated as having a {@code @Nullable} upper

Committable suggestion skipped: line range outside the PR's diff.

Prompt for AI Agents
In nullaway/src/main/java/com/uber/nullaway/handlers/Handler.ja va around lines
460 to 463, the Javadoc for onOverrideMethodTypeVariableUpperBound is missing
documentation for the new state parameter; update the Javadoc block above this
method to add a @param state entry (e.g., "@param state the VisitorState
providing context for the current AST/visitor traversal and utilities such as
type/symbol resolution") so the method documentation is consistent with existing
Javadoc.

Copy link

codecov bot commented Dec 21, 2025 *
edited
Loading

Codecov Report

Patch coverage is 87.50000% with 1 line in your changes missing coverage. Please review.
Project coverage is 88.19%. Comparing base (6acbb64) to head (cf8812b).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...ava/com/uber/nullaway/generics/GenericsChecks.java 0.00% 0 Missing and 1 partial
Additional details and impacted files
@@ Coverage Diff @@
## master #1388 +/- ##
=========================================
Coverage 88.19% 88.19%
Complexity 2616 2616
=========================================
Files 95 95
Lines 8672 8675 +3
Branches 1743 1743
=========================================
+ Hits 7648 7651 +3
Misses 510 510
Partials 514 514

View full report in Codecov by Sentry.
Have feedback on the report? Share it here.

New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

msridhar requested a review from yuxincs December 21, 2025 04:04
msridhar enabled auto-merge (squash) December 21, 2025 04:05
yuxincs approved these changes Dec 21, 2025
msridhar merged commit c457c76 into master Dec 21, 2025
9 of 11 checks passed
msridhar deleted the opt-lib-models-for-upper-bounds branch December 21, 2025 04:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

coderabbitai[bot] coderabbitai[bot] left review comments

yuxincs yuxincs approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants