Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: #3725 JavaParserFacade var type in for-each loop cannot be resolved #3768

Merged
merged 1 commit into from Nov 28, 2022

Conversation

abego
Copy link
Contributor

@abego abego commented Nov 27, 2022

Before this fix it was not possible to resolve the type of the variable used in a for-each loop when the type of the variable was defined as var. This was because the original code only took care of the var with initializer case (e.g. var i = "hello";).

The fix now also covers the usage of a var in a for-each loop, e.g. as in for (var s: names) {...}. The expression at the right side of the : must either be an array or an Iterable.

The bug was originally reported in #3725

Fixes #3725 .

…t be resolved

Before this fix it was not possible to resolve the type of the variable
used in a for-each loop when the type of the variable was defined as `var`.
This was because the original code only took care of the `var with
initializer` case (e.g. `var i = "hello";`).

The fix now also covers the usage of a `var` in a for-each loop, e.g.
as in `for (var s: names) {...}`. The expression at the right side
of the `:` must either be an array or an Iterable.

The bug was originally reported in
javaparser#3725
@codecov
Copy link

codecov bot commented Nov 28, 2022

Codecov Report

Merging #3768 (24c1e6b) into master (d3b54a0) will increase coverage by 0.006%.
The diff coverage is 70.000%.

Impacted file tree graph

@@               Coverage Diff               @@
##              master     #3768       +/-   ##
===============================================
+ Coverage     57.434%   57.440%   +0.006%     
- Complexity      2680      2683        +3     
===============================================
  Files            635       635               
  Lines          33722     33741       +19     
  Branches        5824      5830        +6     
===============================================
+ Hits           19368     19381       +13     
- Misses         12283     12285        +2     
- Partials        2071      2075        +4     
Flag Coverage Δ
AlsoSlowTests 57.440% <70.000%> (+0.006%) ⬆️
javaparser-core 52.648% <ø> (ø)
javaparser-symbol-solver 36.664% <70.000%> (+0.020%) ⬆️
jdk-10 57.436% <70.000%> (+0.009%) ⬆️
jdk-11 57.436% <70.000%> (+0.009%) ⬆️
jdk-12 57.436% <70.000%> (+0.006%) ⬆️
jdk-13 57.436% <70.000%> (+0.006%) ⬆️
jdk-14 57.436% <70.000%> (+0.006%) ⬆️
jdk-15 57.433% <70.000%> (+0.003%) ⬆️
jdk-16 57.433% <70.000%> (+0.003%) ⬆️
jdk-8 57.432% <70.000%> (+<0.001%) ⬆️
jdk-9 57.433% <70.000%> (+0.003%) ⬆️
macos-latest 57.428% <70.000%> (+0.006%) ⬆️
ubuntu-latest 57.425% <70.000%> (+0.006%) ⬆️
windows-latest 57.419% <70.000%> (+0.006%) ⬆️

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

Impacted Files Coverage Δ
...symbolsolver/javaparsermodel/JavaParserFacade.java 74.780% <70.000%> (-0.376%) ⬇️

Continue to review full report at Codecov.

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

@jlerbsc jlerbsc merged commit f8f2a31 into javaparser:master Nov 28, 2022
@jlerbsc
Copy link
Collaborator

jlerbsc commented Nov 28, 2022

Thank you for this contribution

@jlerbsc jlerbsc added this to the next release milestone Nov 28, 2022
@jlerbsc jlerbsc added the PR: Fixed A PR that offers a fix or correction label Nov 28, 2022
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.

Cannot resolve var which has no initializer.
2 participants