-
-
Notifications
You must be signed in to change notification settings - Fork 353
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
Review: bug(*): fix method resolution for inner interfaces #4008
Review: bug(*): fix method resolution for inner interfaces #4008
Conversation
90e2818
to
c4487c7
Compare
This fixes the method CtType#getAllExecutables and handles inner now interfaces correctly as implicitly static. Co-authored-by: I-Al-Istannen <[email protected]>
c4487c7
to
86615d5
Compare
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.
Hi @MartinWitt!
The fix LGTM, but I think the test is a bit unclear in purpose. See what you think of my comments.
As this is a test of CtType.getAllExecutables()
, I would place the test in the CtTypeTest
test class.
|
||
@Test | ||
public void testGetAllMethodsInnerClassExtended() { | ||
// contract: implicit static nested interfaces are correct handled in getAllExecutables and dont throw an error. |
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.
Depending on whether you want the test to verify that there's no crash, or that the correct amount of executables are returned, I would update the contract to state that.
Like I mentioned, invoking a method in a test implicitly tests that it does not crash, and so if you test anything in addition to the fact that the method does not crash (e.g. that it returns the expected amount of executables), the contract does not need to state that it tests that the method doesn't crash. That was a messy sentence but I hope you understand what I mean.
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.
It was a crash while parsing the JDK. I wanted to include a real assertion to guarantee that it's not only not crashing, but working correctly. But you are correct, "Does not crash" is not a useful assertion if we can check if the result is correct.
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.
Looks good!
Currently, spoon fails to resolve methods in a strange edge case, with inner interfaces. Using
CtType#getAllExecutable
on the following type produced aspoon.SpoonException: Cannot create MethodTypingContext for method declared in different ClassTypingContext
In java, all nested interfaces are implicitly static. This fixes the method
CtType#getAllExecutables
and handles now inner interfaces correctly as implicitly static. I'm unsure about the location of the test case, and it's contract. Any suggestions?This bug and the minimal example was discovered/created by @I-Al-Istannen