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

Solving incorrectly a NameExpr Symbol when there is a variable declared after with same name #3674

Open
adrts-iscte opened this issue Aug 24, 2022 · 1 comment

Comments

@adrts-iscte
Copy link

I'm using the "com.github.javaparser:javaparser-symbol-solver-core:3.24.4" release.

Considering de following class:

class Class {

    int attribute;

    private int method() {
        int value = attribute;
        double attribute = 0.0;
        return (int) (attribute + 1);
    }
}

When resolving the line:
int value = attribute;

Setting the JavaParser with the solver as shown in the following code (Kotlin):

StaticJavaParser.setConfiguration(ParserConfiguration().setSymbolResolver(JavaSymbolSolver(CombinedTypeSolver())))
The NameExpr <attribute> provides the VariableDeclarationExpr <double attribute = 0.0> instead of the FieldDeclaration <int attribute;>.

Am I doing anything wrong or is it just a bug?

@jlerbsc
Copy link
Collaborator

jlerbsc commented Aug 24, 2022

This is indeed a known bug but for the moment there is no solution to this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants