Skip to content

Fix: issue 4188 UnsolvedSymbolException resolving MethocCallExpr using MethodReferenceExpr#4931

Merged
jlerbsc merged 1 commit intojavaparser:masterfrom
jlerbsc:master
Dec 19, 2025
Merged

Fix: issue 4188 UnsolvedSymbolException resolving MethocCallExpr using MethodReferenceExpr#4931
jlerbsc merged 1 commit intojavaparser:masterfrom
jlerbsc:master

Conversation

@jlerbsc
Copy link
Copy Markdown
Collaborator

@jlerbsc jlerbsc commented Dec 19, 2025

Fixes #4188 .

This PR improves the resolution of a reference expression of the form Primary, followed by :: and a method name.".

JLS §15.13.1: "If the method reference expression has the form Primary :: [TypeArguments] Identifier"

This is FORM 2: The scope is an expression (e.g., foo, myString, System.out)

CRITICAL: In this form, the expression is evaluated and becomes the BOUND RECEIVER at method reference creation time, not at invocation time.

The potentially applicable methods are the member methods of the type of the Primary that are not static

For bound instance methods: ALL functional interface parameters map to method parameters
The receiver is NOT part of paramTypes - it's already bound to the expression result

Example from failing test:

Foo foo = new Foo();
Optional<Integer> priority = Optional.of(4);
priority.map(foo::convert).orElse("0");

Analysis:

  • scope = foo (a Primary expression, not a type)
  • foo is evaluated → becomes bound receiver
  • map() expects Function<Integer, String>
  • paramTypes = [Integer] (from Function's parameter type)
  • convert(int) signature: takes 1 parameter
  • ALL paramTypes [Integer] go to method parameters
  • Match: convert(int) with [Integer] ✓

@codecov
Copy link
Copy Markdown

codecov bot commented Dec 19, 2025

Codecov Report

❌ Patch coverage is 53.65854% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.444%. Comparing base (0e6f25b) to head (d69555f).
⚠️ Report is 9 commits behind head on master.

Files with missing lines Patch % Lines
...symbolsolver/javaparsermodel/JavaParserFacade.java 57.894% 7 Missing and 9 partials ⚠️
.../java/com/github/javaparser/ast/expr/TypeExpr.java 0.000% 3 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@               Coverage Diff               @@
##              master     #4931       +/-   ##
===============================================
- Coverage     58.445%   58.444%   -0.002%     
- Complexity      2560      2561        +1     
===============================================
  Files            689       689               
  Lines          39553     39566       +13     
  Branches        7176      7182        +6     
===============================================
+ Hits           23117     23124        +7     
  Misses         13497     13497               
- Partials        2939      2945        +6     
Flag Coverage Δ
AlsoSlowTests 58.444% <53.658%> (-0.002%) ⬇️
javaparser-core 58.444% <53.658%> (-0.002%) ⬇️
javaparser-symbol-solver 58.444% <53.658%> (-0.002%) ⬇️
jdk-10 58.010% <53.658%> (+0.001%) ⬆️
jdk-11 58.007% <53.658%> (-0.002%) ⬇️
jdk-12 58.009% <53.658%> (+0.001%) ⬆️
jdk-13 58.009% <53.658%> (-0.002%) ⬇️
jdk-14 58.242% <53.658%> (-0.004%) ⬇️
jdk-15 58.244% <53.658%> (-0.002%) ⬇️
jdk-16 58.217% <53.658%> (-0.004%) ⬇️
jdk-17 58.371% <53.658%> (-0.002%) ⬇️
jdk-18 58.371% <53.658%> (-0.002%) ⬇️
jdk-8 57.852% <55.000%> (-0.003%) ⬇️
jdk-9 58.005% <53.658%> (-0.002%) ⬇️
macos-latest 58.436% <53.658%> (-0.002%) ⬇️
ubuntu-latest 58.431% <53.658%> (-0.002%) ⬇️
windows-latest 58.426% <53.658%> (-0.002%) ⬇️

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

Files with missing lines Coverage Δ
.../java/com/github/javaparser/ast/expr/TypeExpr.java 44.444% <0.000%> (-4.041%) ⬇️
...symbolsolver/javaparsermodel/JavaParserFacade.java 75.718% <57.894%> (-2.169%) ⬇️

... and 6 files with indirect coverage changes


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 0b18881...d69555f. 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 f11a1d4 into javaparser:master Dec 19, 2025
34 of 35 checks passed
@jlerbsc jlerbsc added this to the next release milestone Dec 19, 2025
@jlerbsc jlerbsc added the PR: Fixed A PR that offers a fix or correction label Dec 19, 2025
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.

UnsolvedSymbolException resolving MethodCallExpr using MethodReferenceExpr

1 participant