Introduce @UnannnotatedFor - #856
Draft
aosen-xiong wants to merge 16 commits into
Draft
Conversation
@UnAnnnotatedFor
Collaborator
Author
|
TODO: change Retention for both annotatedfor and unannotatedfor qualifiers. |
Keep only the introduction of @UnannotatedFor. Conflicts between @AnnotatedFor and @UnannotatedFor on the same element are left for a separate change, so drop what this branch had toward them: * SourceChecker: revert to master. Its only effect was to let an @UnannotatedFor override an @AnnotatedFor on the same element; for every other element it returned what master already returned, and no test covers it. It also declared an unused ANNOTATEDFOR_CONFLICT message key with no entry in any messages.properties, and iterated both annotation arrays after a null check that only required one of them to be non-null. * QualifierDefaults: remove a commented-out copy of isElementUnannotatedForThisChecker and restore a Javadoc typo. The only merge conflict was an import in AnnotatedTypeFactory.
Conflict in QualifierDefaults: eisop#1331 removed isElementAnnotatedForThisChecker and its elementAnnotatedFors cache from QualifierDefaults, so this branch's changes to that method are obsolete. Take master's side; the @UnannotatedFor logic is ported to the shared lookup in a follow-up commit. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…or scope @UnannotatedFor was defined and given an AnnotatedTypeFactory helper, but its effect was implemented in QualifierDefaults.isElementAnnotatedForThisChecker, which eisop#1331 removed. Implement it in the lookup that replaced it, BaseTypeChecker.isElementAnnotatedForThisCheckerOrUpstreamChecker, so that it governs both conservative defaults and warning suppression. @AnnotatedFor is tested first, so @UnannotatedFor is purely subtractive: it stops the walk to the enclosing element, and never overrides an explicit @AnnotatedFor on the same element. A nested @AnnotatedFor takes effect again. Both shouldSuppressWarnings overloads accumulated the @AnnotatedFor answer over every enclosing declaration, and the TreePath overload additionally asked about the enclosing package. That defeated the exclusion: an @UnannotatedFor class in an @AnnotatedFor package was defaulted as unchecked code but still had its warnings reported. Ask isElementAnnotatedForThisCheckerOrUpstreamChecker once, about the innermost declaration; it already resolves enclosing scopes, so the per-level query was redundant work even before this change. Only one cache is needed. The element's cached boolean is the fully-resolved scope answer, including @UnannotatedFor exclusions. Also mirror doesUnannotatedForApplyToThisChecker on its @AnnotatedFor sibling, and correct the @UnannotatedFor javadoc, which claimed an effect on bytecode although the annotation has source retention. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1292.
Do it after #1996, we would likely need the same subpackage instrumentation.