-
Notifications
You must be signed in to change notification settings - Fork 160
Avoid dodgy cast in InferenceContext18.solve() #4522
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
base: master
Are you sure you want to change the base?
Conversation
|
|
Yes, change the author email in your git commit, amend and force push it again. |
|
You can also set it permanently in |
dbb6958 to
5fed78b
Compare
|
Thanks for the PR
True, but since all these types are internal, we can easily see that "almost all" classes implementing
Using such a wrapper in itself feels a bit like a workaround, too. Maybe it's time to invent an interface |
|
I just came across another candidate that might benefit from the proposed interface |
The same thought occurred to me, but I was trying to submit the minimum possible diff in the hopes that it would be more likely to get accepted. I could try implementing such a thing instead if you want. |
Small is beautiful. Small without a wrapper is even more beautiful. 😄 I don't think introducing a slim interface As a proof of its usefulness you might even want to use it also in |
eb6430a to
45a284b
Compare
|
Looks like the pipeline fell victim to another occurrence of eclipse-platform/eclipse.platform.releng.aggregator#2660. Rebased again to see if that fixes it. |
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.
essentially looks good.
After we discussed that small is beautiful I believe you could still shrink the change a bit, see detailed comments.
| default int nameSourceStart() { return sourceStart(); } | ||
| default int nameSourceEnd() { return sourceEnd(); } |
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 don't see much benefit in declaring nameSourceStart()/End() here. Those don't seem to be useful for ASTNode and many of its subclasses. Nor do I see this called via the Location interface. Am I missing anything?
| TypeConstants.JAVA_LANG_OBJECT, | ||
| this.referenceContext, | ||
| this.environment.missingClassFileLocation, false, null/*resolving j.l.O is not specific to any referencing type*/); | ||
| this.environment, false, null/*resolving j.l.O is not specific to any referencing type*/); |
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.
this change looks unmotivated to me. Wouldn't just changing the signature of isClassPathCorrect() simplify things already?
I don't think that method has use for the LookupEnvironment itself.
What it does
InferenceContext18.solve() was assuming that it is always safe to cast from
InvocationSitetoASTNode. These two classes are not actually related, but the only thing the resulting variable was being used for was to callsourceStart()andsourceEnd(), two methods that are defined on both classes.A cleaner solution is to use the existing
InvocationSite.EmptyWithAstNodewrapper class, which includes a passthrough implementation of the two relevant methods.How to test
This should be functionally equivalent to the previous code, but the old cast was very inconvenient for my project that uses the ECJ as a base for implementing operator overloading in Java.
Author checklist