Skip to content

Compute a call's executable type once per generic inference - #1896

Merged
msridhar merged 1 commit into
uber:masterfrom
ericschlarmann:fix-exponential-chained-generic-inference
Sep 28, 2026
Merged

msridhar merged 1 commit into
uber:masterfrom
ericschlarmann:fix-exponential-chained-generic-inference

Conversation

@ericschlarmann

@ericschlarmann ericschlarmann commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Since #1654, the executable type used for inference is the method's type as a member of its receiver, and computing it infers the receiver when the receiver is itself a generic call. inferCallType computed it twice for a call not yet inferred (constraints, then return type), and runInferenceForCall a third time for lambda argument types. Inference run from dataflow is never cached, so every generic call in a receiver chain doubled the work below it: checking a fluent chain such as r.path(..).entity(..).isEqualTo(..) repeated n times took O(4^n).

Compute the executable type once and pass it to runInferenceForCall and generateConstraintsForCall. At 9 links, dataflow inference runs drop from 524,259 to 315; a 96-link chain now checks in under 1s.

Adds GenericMethodTests.longChainOfGenericInstanceMethodCalls, which times out on master and passes in about 0.1s with the fix. No existing test's diagnostics change.

I used Claude Code to bisect the regression to #1654, find the cause and write the fix and test. I have reviewed and understood all the changes.

Assisted-by: Claude Code (claude-opus-5-5)

Summary by CodeRabbit

  • Bug Fixes

    • Improved generic method-call inference consistency, including for nested calls and chained method calls.
  • Tests

    • Added a regression test covering nullable-argument detection in a long chain of generic method calls.

Since uber#1654, the executable type used for inference is the method's type
as a member of its receiver, and computing it infers the receiver when
the receiver is itself a generic call.  inferCallType computed it twice
for a call not yet inferred (constraints, then return type), and
runInferenceForCall a third time for lambda argument types.  Inference
run from dataflow is never cached, so every generic call in a receiver
chain doubled the work below it: checking a fluent chain such as
`r.path(..).entity(..).isEqualTo(..)` repeated n times took O(4^n).

Compute the executable type once and pass it to runInferenceForCall and
generateConstraintsForCall.  At 9 links, dataflow inference runs drop
from 524,259 to 315; a 96-link chain now checks in under 1s.

Assisted-by: Claude Code (claude-opus-5-5)
@CLAassistant

CLAassistant commented Sep 28, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderabbitai

coderabbitai Bot commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: uber/NullAway/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 50652e1e-604c-446b-b063-90571a9abf24

📥 Commits

Reviewing files that changed from the base of the PR and between d5bcf3c and 664b66d.

📒 Files selected for processing (2)
  • nullaway/src/main/java/com/uber/nullaway/generics/GenericsChecks.java
  • nullaway/src/test/java/com/uber/nullaway/jspecify/GenericMethodTests.java

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.


Walkthrough

Generic-call inference now computes executable types at call sites and reuses them for constraint generation, return-type substitution, and argument mapping. Nested generic calls and generic method-type substitution also pass computed executable types into inference. A new timeout-limited test checks that a 24-segment generic method chain reports a nullable argument at its final .path(null) call.

Suggested reviewers: msridhar

Priority: ⬇️ Low

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 664b6

No merge-blocking issue is established; this change is ready for normal checks.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 62.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: computing a generic call's executable type once during inference.
Description check ✅ Passed The description directly explains the performance problem, the implementation change, and the added regression test.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

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.

@msridhar msridhar 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 for the great fix and the test! I had a feeling I missed some pathological cases like this.

@msridhar
msridhar enabled auto-merge (squash) September 28, 2026 16:18
@codecov

codecov Bot commented Sep 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.67%. Comparing base (51ef189) to head (664b66d).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1896      +/-   ##
============================================
+ Coverage     87.62%   87.67%   +0.05%     
  Complexity     3499     3499              
============================================
  Files           110      110              
  Lines         11642    11641       -1     
  Branches       2403     2403              
============================================
+ Hits          10201    10206       +5     
+ Misses          664      657       -7     
- Partials        777      778       +1     

☔ View full report in Codecov by Harness.
📢 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
msridhar merged commit f4a1e93 into uber:master Sep 28, 2026
19 checks passed
@msridhar

Copy link
Copy Markdown
Collaborator

@ericschlarmann how critical is this fix for your codebase? Do you need a release soon that includes it?

@ericschlarmann

Copy link
Copy Markdown
Contributor Author

@ericschlarmann how critical is this fix for your codebase? Do you need a release soon that includes it?

Thanks for the quick review and merge!
We cannot upgrade before this is released, so a quick release would of course be appreciated. Until then, we can just coast on the old version, so I wouldn't say super critical ;)

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.

3 participants