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

CtFieldReference.getDefaultExpression() returns initializer from a field of another class #1213

Closed
bastik opened this issue Mar 10, 2017 · 1 comment
Labels

Comments

@bastik
Copy link

bastik commented Mar 10, 2017

Hi, I'm trying to collect and evaluate certain strings in the source repository.

I tried VisitorPartialEvaluator, but it runs into an infinite loop. The reason of this is that fields get mixed up. The code setup is like this:

class BaseClass {
    public final static String PREFIX = "BasePrefix";
}

class ClassB {
    public final static String PREFIX = BaseClass.PREFIX + ".b";
    public String getKey() {
        return BaseClass.PREFIX + ".x";
    }
}

Now if you try to read the return value of the getKey() method, the CtFieldReference object will return the default value of ClassB.PREFIX, not BaseClass.PREFIX.

@tdurieux
Copy link
Collaborator

tdurieux commented Mar 10, 2017

this bug is related to #756
I don't know how to resolve this bug without breaking #756

Or we have to introduce a method getCtField() in CtfieldAcess in order to know the target of the CtFieldAccess.

surli added a commit to surli/spoon that referenced this issue Mar 10, 2017
@surli surli added the bug label Mar 10, 2017
surli added a commit to surli/spoon that referenced this issue Mar 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants