-
Notifications
You must be signed in to change notification settings - Fork 26
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
If one link of an @Implies
chain is bad, are the following links still followed?
#314
Comments
(Ugh, I was going to post a short followup, but it's become long. Maybe I can come up with another post that will be short.) In thinking about this, I've been thinking in terms of two subtly different categories of badness:
By "This implication link is bad," I mean something like my first example above: By "The annotation added by this implication link is bad," I mean something like this: @Implies(Nullable.class)
@interface MyNullable
@MyNullable @NonNull String s; In that case, the abstract idea that I had been focused on the first category when I wrote my initial post, but we should figure out if it actually makes sense to treat the categories separately. Returning to my initial post: My second example from that post is... at least mostly like the first one, but I can tweak the example to make it more distinct: @Target({MODULE, METHOD})
@interface One {}
@Implies(One.class)
@Target({MODULE, FIELD})
@interface Two {}
@Implies(Two.class)
@Target({MODULE, FIELD, METHOD})
@interface Three {}
@Three void foo(); In this new example, there's nothing wrong with any individual implication edge or even with the implication chain as a whole. (I mean, I think we're OK with having an annotation be applicable to more locations than the annotation it implies is, right? as long as there's some overlap, in the broad sense of "overlap" permitted by #124?) But if we were to evaluate the For that matter, we can produce that case without appealing to multiple @Target(TYPE_USE)
@interface ApplicableToLocalVariables {}
@Implies(ApplicableToLocalVariables.class)
@Target(TYPE_USE)
@interface NotApplicableToLocalVariables {}
void foo() {
@NotApplicableToLocalVariables String s;
} That's pretty perverse, especially since JSpecify cannot know in general whether a particular annotation is applicable to top-level local-variable types or not. (#136 could help with that particular case, but it wouldn't cover other cases we care about, like outer types and primitives. Maybe this also relates to the kevinb9n goal of distinguishing |
Without thinking about this in great detail (ha!), I'm inclined to aim for the same kind simplicity as proposed in #311: We'd start by following every The main remaining question to me at that point is the original one: If |
For example (from #240 (comment)), what if one link is bad because it implies an annotation with a required element?
We already know (from #240) that
foo()
is not considered to have@Two
"present." Should it also not be considered to have@One
"present?"That would be justified by a rule that a chain of implication stops entirely at an unrecognized edge.
We could imagine other variants of this, too, like one that involves a difference in
@Target
. (I forget whether we have a proper writeup of that somewhere, but I see I linked #34 (comment) in a discussion of it previously, so let's go with that.)As in the previous example, the question is whether
foo()
is considered to have@One
"present."The text was updated successfully, but these errors were encountered: