Skip to content
New issue

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

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

Already on GitHub? # to your account

Super calls not resolved #99

Closed
Masrepus opened this issue May 15, 2020 · 6 comments · Fixed by #106
Closed

Super calls not resolved #99

Masrepus opened this issue May 15, 2020 · 6 comments · Fixed by #106
Assignees
Labels
bug Something isn't working java Related to Java language parsing

Comments

@Masrepus
Copy link
Contributor

Example:

public class A {
    public int getInt() {
        return 42;
    }
}

public class B extends A {
    @Override
    public int getInt() {
        return super.getInt() + 2;
    }
}
@Masrepus Masrepus added bug Something isn't working java Related to Java language parsing labels May 15, 2020
@Masrepus Masrepus self-assigned this May 15, 2020
@oxisto
Copy link
Member

oxisto commented May 15, 2020

I remember that there was an issue that I discovered in the Java Parser related to super-Calls not properly resolved. Apparently I did not open an issue on this, just discussed it on gitter. Might be worth finding out if this relates to that or if it is an issue specific to the CPG.

@Masrepus
Copy link
Contributor Author

I figured that this might be somehow JavaParser related, as it is created as a static call, which makes little sense. But I will have to check the root cause in more detail. I would probably just fix it on our side for now, but we can surely pass this on to the JavaParser guys if it really is a problem coming from upstream 👍

@oxisto
Copy link
Member

oxisto commented May 15, 2020

Can you make a quick check whether this may be resolved in the latest JP version? There are some fixes related to super functions in 3.15.18+, we are at 3.15.10

@Masrepus
Copy link
Contributor Author

super.getInt() is still resolved as a static call. Is there any changelog or do you need to go through all commits for that?

@oxisto
Copy link
Member

oxisto commented May 15, 2020

I was looking at javaparser/javaparser@5d63f63 which sounded like in general super calls are resolved but not for specific cases

@Masrepus
Copy link
Contributor Author

Ah I just double checked, the method itself is correctly resolved as A.getInt. So the problem is on our side as it seems

Masrepus added a commit that referenced this issue Jun 4, 2020
- add inheritance information also for CXX files
- split supertypes into superclasses and implemented interfaces -> needed for correct Java super call resolving
- automatically add "this" field to dummy records as well
- correctly resolve super.call() and BaseName.super.call() according to JLS 13
- unify handling of the dedicated "unknown declarations" translation unit
- remove transitive closure for inheritance
Masrepus added a commit that referenced this issue Jun 4, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working java Related to Java language parsing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants