You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A meta-annotation to express "incompatible with <other annotations>" #101
designAn issue that is resolved by making a decision, about whether and how something should work.new-featureAdding something entirely new for users, not improving what's there
@IncompatibleWith({Nullable.class, NullUnspecified.class})
public @interface NonNull {...}
This would express that it is invalid to use this annotation and any of the listed ones together in the exact same spot. (Of course, it would not prevent two listed annotations from appearing together in the absence of the annotated annotation.)
By convention we could do it in both directions but only one would be necessary.
A compliant checker would not permit the conflicting annotations to appear together in code it is analyzing. But what if they appear together in some dependency of the code being analyzed?
I would suggest that checkers absolutely should not choose based on position (even if that order is preserved in the class file). And trying to specify an order of precedence somehow feels like a big waste of complexity with little to gain. And deciding to just ignore them all won't lead to anything good.
So, we might actually want the @IncompatibleWith docs to explicitly condone giving an error even if it's a dependency that contains the violation.
If there are annotations that express a subtyping relationship, such as @SubtypeOf, they can serve this purpose. We might still need @IncompatibleWith, but maybe not for type annotations.
The Checker Framework, by contrast, has more reason to support @SubtypeOf: It is part of what lets users define arbitrary new type systems.
Kevin has replied to my concerns on the other thread. I agree that there's some value to the annotations proposed in both this issue and #109, but both still feel to me to not be part of the minimum viable product.
(I can see making the actual release of said annotations lower priority, for sure. I just want us to be thinking ahead a bit, so that in 5 years we have a nice stable of stable annotations, where learning one actually helps you to learn another.)
One potentially nice thing about meta-annotations in general is that it lets us make changes in the annotations themselves and then have the behavior change automatically picked up by tools. Alternatively, that is a potentially scary thing :) But I'm not sure if it's necessarily any scarier than the idea that we'd make significant changes to existing annotations period.
designAn issue that is resolved by making a decision, about whether and how something should work.new-featureAdding something entirely new for users, not improving what's there
Activity
kevinb9n commentedon May 8, 2020
A compliant checker would not permit the conflicting annotations to appear together in code it is analyzing. But what if they appear together in some dependency of the code being analyzed?
I would suggest that checkers absolutely should not choose based on position (even if that order is preserved in the class file). And trying to specify an order of precedence somehow feels like a big waste of complexity with little to gain. And deciding to just ignore them all won't lead to anything good.
So, we might actually want the
@IncompatibleWithdocs to explicitly condone giving an error even if it's a dependency that contains the violation.mernst commentedon May 8, 2020
If there are annotations that express a subtyping relationship, such as
@SubtypeOf, they can serve this purpose. We might still need@IncompatibleWith, but maybe not for type annotations.cpovirk commentedon May 11, 2020
For jspecify, supporting this feels somewhat speculative to me, similar to how I feel about
@NegatedBy/@NegatedOf.The Checker Framework, by contrast, has more reason to support
@SubtypeOf: It is part of what lets users define arbitrary new type systems.Kevin has replied to my concerns on the other thread. I agree that there's some value to the annotations proposed in both this issue and #109, but both still feel to me to not be part of the minimum viable product.
kevinb9n commentedon May 11, 2020
(I can see making the actual release of said annotations lower priority, for sure. I just want us to be thinking ahead a bit, so that in 5 years we have a nice stable of stable annotations, where learning one actually helps you to learn another.)
cpovirk commentedon Feb 1, 2021
One potentially nice thing about meta-annotations in general is that it lets us make changes in the annotations themselves and then have the behavior change automatically picked up by tools. Alternatively, that is a potentially scary thing :) But I'm not sure if it's necessarily any scarier than the idea that we'd make significant changes to existing annotations period.
This is similar to a discussion about using
@Targetvs. hardcoding that information in checkers.