Skip to content

fix: handle wildcard actualType in matchTypeParameters (issue #3751)#5029

Merged
jlerbsc merged 1 commit into
javaparser:masterfrom
jlerbsc:master
May 30, 2026
Merged

fix: handle wildcard actualType in matchTypeParameters (issue #3751)#5029
jlerbsc merged 1 commit into
javaparser:masterfrom
jlerbsc:master

Conversation

@jlerbsc

@jlerbsc jlerbsc commented May 30, 2026

Copy link
Copy Markdown
Collaborator

Fixes #3751 .

When Stream.collect() is called with a Collector whose intermediate
accumulation type is a wildcard (e.g. Collectors.toList() returns
Collector<T, ?, List>), matchTypeParameters threw
UnsupportedOperationException trying to bind the formal type variable
'A' against the wildcard '?'.
Apply capture-conversion rules: a bounded wildcard (? extends / ? super)
contributes its declared bound as the inferred type; an unbounded wildcard
'?' carries no type information and is skipped. This leaves 'A' unresolved
while still allowing the return type 'R' to be correctly inferred from the
remaining type arguments.
Add Javadoc to matchTypeParameters documenting all handled cases.
Add two regression tests in MethodCallExprContextResolutionTest:

@codecov

codecov Bot commented May 30, 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.686%. Comparing base (11df31a) to head (5874940).
⚠️ Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
...avaparsermodel/contexts/MethodCallExprContext.java 0.000% 4 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@               Coverage Diff               @@
##              master     #5029       +/-   ##
===============================================
- Coverage     58.693%   58.686%   -0.008%     
  Complexity      2595      2595               
===============================================
  Files            702       702               
  Lines          40277     40282        +5     
  Branches        7340      7342        +2     
===============================================
  Hits           23640     23640               
- Misses         13663     13667        +4     
- Partials        2974      2975        +1     
Flag Coverage Δ
AlsoSlowTests 58.686% <0.000%> (-0.008%) ⬇️
javaparser-core 58.686% <0.000%> (-0.008%) ⬇️
javaparser-symbol-solver 58.686% <0.000%> (-0.008%) ⬇️
jdk-10 58.254% <0.000%> (-0.010%) ⬇️
jdk-11 58.258% <0.000%> (-0.008%) ⬇️
jdk-12 58.256% <0.000%> (-0.010%) ⬇️
jdk-13 58.258% <0.000%> (-0.008%) ⬇️
jdk-14 58.489% <0.000%> (-0.008%) ⬇️
jdk-15 58.489% <0.000%> (-0.008%) ⬇️
jdk-16 58.464% <0.000%> (-0.008%) ⬇️
jdk-17 58.613% <0.000%> (-0.008%) ⬇️
jdk-18 58.613% <0.000%> (-0.008%) ⬇️
jdk-8 58.093% <0.000%> (-0.008%) ⬇️
jdk-9 58.257% <0.000%> (-0.005%) ⬇️
macos-latest 58.661% <0.000%> (-0.008%) ⬇️
ubuntu-latest 58.656% <0.000%> (-0.008%) ⬇️
windows-latest 58.668% <0.000%> (-0.008%) ⬇️

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

Files with missing lines Coverage Δ
...avaparsermodel/contexts/MethodCallExprContext.java 82.899% <0.000%> (-1.571%) ⬇️

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 2761dca...5874940. 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 ed82314 into javaparser:master May 30, 2026
34 of 35 checks passed
@jlerbsc jlerbsc added this to the next release milestone May 30, 2026
@jlerbsc jlerbsc added the PR: Fixed A PR that offers a fix or correction label May 30, 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.

RuntimeException when using calculateResolvedType for method call to Stream.collect

1 participant