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

Enforce @TargetLocations annotation #1919

Open
mernst opened this issue Mar 28, 2018 · 2 comments
Open

Enforce @TargetLocations annotation #1919

mernst opened this issue Mar 28, 2018 · 2 comments
Milestone

Comments

@mernst
Copy link
Member

mernst commented Mar 28, 2018

If qualifier Q has a @TargetLocations meta-annotation and the programmer writes @Q at any location that is not listed in Q's @TargetLocations meta-annotation, then the Checker Framework should issue a warning. This warning may be suppressed (say, for making default annotations explicit in test cases).

(Issue ported from #515 which had become cluttered with other discussion.)

@Maxi17
Copy link
Contributor

Maxi17 commented Aug 15, 2019

@mernst @smillst
Fixing this issue, I wanted to ask if some annotations need more @TargetLocations arguments.
For example, @BottomVal can be used on parameters too, even though it doesn't have TypeUseLocation.PARAMETER as argument to @TargetLocations (on fields too).
You can see my progress here: my branch (any opinion about it before opening the PR against CF master would be appreciated). Thank you!

@smillst
Copy link
Member

smillst commented Aug 19, 2019

@Maxi17 It's possible that some annotations need more target locations, but I don't think @BottomVal is one of them. Note the target locations specify where an annotation may be written by a programmer, but a type system by refine or default regardless of the target location of a qualifier. So, your code should check for annotations explicitly written on trees, not that AnnotatedTypeMirror for elements. See the code in org.checkerframework.checker.lock.LockVisitor#issueErrorIfGuardSatisfiedAnnotationInUnsupportedLocation for an example.

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

No branches or pull requests

3 participants