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

fix: typecast on conditional #753

Merged
merged 1 commit into from
Jul 21, 2016

Conversation

danglotb
Copy link
Member

Hello, TypeCast on CtConditional are not cloned or used in equals. Here an example:

Snippet code:

public class ConditionalRes {
    byte [] b = new byte [] { true ? 1 : 2};
}

Spoon code:

@Test
public void testCloneCastConditional() throws Exception {
    final Launcher launcher = new Launcher();
    launcher.setSourceOutputDirectory("./target/trash");
    launcher.addInputResource("./src/test/resources/spoon/test/visitor/ConditionalRes.java");
    launcher.addProcessor(new AbstractProcessor<CtConditional<?>>() {
        @Override
        public void process(CtConditional<?> conditional) {
            conditional.addTypeCast(getFactory().Type().bytePrimitiveType());
            CtConditional clone = conditional.clone();
            System.out.println(conditional);
            System.out.println(clone);
            System.out.println(conditional.equals(clone));
        }
    });
    launcher.run();
}

Output:

((byte) (true ? 1 : 2))
true ? 1 : 2
true

@monperrus monperrus merged commit 27e59ec into INRIA:master Jul 21, 2016
@tdurieux tdurieux mentioned this pull request Sep 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants