Skip to content

Fix lambda type inference for fully-qualified static method calls (#3476#5019

Merged
jlerbsc merged 2 commits into
javaparser:masterfrom
jlerbsc:master
May 19, 2026
Merged

Fix lambda type inference for fully-qualified static method calls (#3476#5019
jlerbsc merged 2 commits into
javaparser:masterfrom
jlerbsc:master

Conversation

@jlerbsc

@jlerbsc jlerbsc commented May 19, 2026

Copy link
Copy Markdown
Collaborator

Fixes #3476 .

MethodResolutionLogic.inferTypes() did not handle subtype relationships: when matching ArrayList against List, the differing qualified names caused the method to return immediately without inferring T = String. This left lambda parameters typed as LambdaConstraintType{bound=TypeVariable} instead of LambdaConstraintType{bound=String}, breaking resolution of any method call inside the lambda.

The fix walks the ancestors of the source type to find a matching supertype when qualified names differ, consistent with the existing approach in InferenceContext.registerCorrespondance().

Only triggered via the FieldAccessExpr code path (fully-qualified class name); the NameExpr path (imported class) already used matchTypeParameters() which handled subtypes correctly.

@codecov

codecov Bot commented May 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.704%. Comparing base (fbfd811) to head (a4ef5de).
⚠️ Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
...parser/resolution/logic/MethodResolutionLogic.java 0.000% 5 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@               Coverage Diff               @@
##              master     #5019       +/-   ##
===============================================
- Coverage     58.711%   58.704%   -0.008%     
  Complexity      2592      2592               
===============================================
  Files            702       702               
  Lines          40217     40222        +5     
  Branches        7327      7329        +2     
===============================================
  Hits           23612     23612               
- Misses         13634     13639        +5     
  Partials        2971      2971               
Flag Coverage Δ
AlsoSlowTests 58.704% <0.000%> (-0.008%) ⬇️
javaparser-core 58.704% <0.000%> (-0.008%) ⬇️
javaparser-symbol-solver 58.704% <0.000%> (-0.008%) ⬇️
jdk-10 58.274% <0.000%> (-0.010%) ⬇️
jdk-11 58.273% <0.000%> (-0.008%) ⬇️
jdk-12 58.275% <0.000%> (-0.005%) ⬇️
jdk-13 58.275% <0.000%> (-0.008%) ⬇️
jdk-14 58.504% <0.000%> (-0.010%) ⬇️
jdk-15 58.507% <0.000%> (-0.008%) ⬇️
jdk-16 58.482% <0.000%> (-0.008%) ⬇️
jdk-17 58.631% <0.000%> (-0.008%) ⬇️
jdk-18 58.631% <0.000%> (-0.008%) ⬇️
jdk-8 58.110% <0.000%> (-0.010%) ⬇️
jdk-9 58.274% <0.000%> (-0.005%) ⬇️
macos-latest 58.679% <0.000%> (-0.008%) ⬇️
ubuntu-latest 58.674% <0.000%> (-0.008%) ⬇️
windows-latest 58.686% <0.000%> (-0.008%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...parser/resolution/logic/MethodResolutionLogic.java 0.000% <0.000%> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6962fa6...a4ef5de. Read the comment docs.

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

@jlerbsc jlerbsc merged commit 5a43c63 into javaparser:master May 19, 2026
34 of 35 checks passed
@jlerbsc jlerbsc added this to the next release milestone May 19, 2026
@jlerbsc jlerbsc added the PR: Fixed A PR that offers a fix or correction label May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: Fixed A PR that offers a fix or correction

Projects

None yet

Development

Successfully merging this pull request may close these issues.

An error occurred in calculateresolvedtype of lambdaexpr

1 participant