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

Inability to write annotations on the outer class portion of an inner class name #3562

Closed
jwaataja opened this issue Aug 5, 2020 · 2 comments · Fixed by #3583
Closed

Inability to write annotations on the outer class portion of an inner class name #3562

jwaataja opened this issue Aug 5, 2020 · 2 comments · Fixed by #3583
Assignees
Milestone

Comments

@jwaataja
Copy link
Contributor

jwaataja commented Aug 5, 2020

Dataflow seems to break with inner class types.

import org.checkerframework.checker.tainting.qual.*;

public class C {
    void method(@Tainted Inner param) {
        @Tainted C. @Untainted Inner local = param;
    }

    class Inner {
    }
}

I get this error,

C.java:5: error: [type.invalid.conflicting.annos] invalid type: conflicting annotations [@Tainted, @Untainted] in type "@Tainted C.@Tainted @Untainted Inner"
        @Tainted C. @Untainted Inner local = param;
                                     ^

I would expect to instead get an invalid assignment error. It seems dataflow tries to replace the inner type but doesn't remove the old annotation.

@jwaataja
Copy link
Contributor Author

jwaataja commented Aug 7, 2020

I originally thought this had something to do with dataflow, but it didn't. Simplified test case:

import org.checkerframework.checker.tainting.qual.*;

public class C {
    @Tainted C. @Untainted Inner field;

    class Inner {
    }
}

The JLS specifies that on fields, the annotation immediately before the type is a modifier of the field itself, so it makes sense that both annotations are written on the Inner class. However, this raises the question of how to specify the type @Tainted C. @Untainted Inner. That is, an @Untainted instance of Inner where C.this has type @Tainted. There's no way to write the annotation on C specifically, both annotations apply to the inner class.

@jwaataja jwaataja changed the title Dataflow doesn't correctly replace annotations on inner class during inference Inability to write annotations on the outer class portion of an inner class name Aug 7, 2020
@smillst smillst self-assigned this Aug 7, 2020
@smillst smillst added this to the High milestone Aug 7, 2020
@smillst
Copy link
Member

smillst commented Aug 10, 2020

I've confirmed this is a bug in they way the Checker Framework decodes annotations from VariableTrees. I'm working on fixing it.

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 a pull request may close this issue.

2 participants