-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix for #3710 by cutting off resolution loops involving object creation steps. #4704
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 for #3710 by cutting off resolution loops involving object creation steps. #4704
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #4704 +/- ##
===============================================
- Coverage 58.198% 58.194% -0.005%
Complexity 2497 2497
===============================================
Files 670 670
Lines 38719 38720 +1
Branches 7022 7023 +1
===============================================
- Hits 22534 22533 -1
- Misses 13293 13295 +2
Partials 2892 2892
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
7bc20b7
to
dece4d5
Compare
// is not the same as the current node. | ||
while (notMethodNode instanceof MethodCallExpr | ||
|| notMethodNode instanceof FieldAccessExpr | ||
|| (notMethodNode instanceof ObjectCreationExpr && notMethodNode.hasScope()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure that the expression new A().new B() can be solved correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment explaining simply and clearly why this has been added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added a comment, and a unit test for the case you mentioned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact, I added two unit tests :)
"com.github.javaparser.symbolsolver.Outer.make()", resolvedMethod.getQualifiedSignature()); | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please include these classes in the source code to be parsed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
This is adapted from my own example and the example in 3710, to make up a more-or-less minimal reproduction case.
Without this check, the symbol resolver would loop between resolving a method call (used as scope argument for a new object creation) and resolving the method call's scope.
353f1ad
to
c189a15
Compare
…ner class creation resolution with a constructor base work as expected.
c189a15
to
84441d0
Compare
Thank you for your contribution |
Fixes #3710.
The idea of the fix is that the scope in inner class object creation expressions, e.g.,
makeOuter().new Inner()
, can cause resolution loops in just the same way that the scope of a field access or method call can, and should be handled in the same way.