Conversation
The tests cover which member type a simple name refers to, which depends on accessibility and on hiding, and when a name refers to a type variable rather than to a type declaration that shadows it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…ework-fork-mernst-branch-relevance-type-variable-upper-bound into javaparserutil-unit-tests
…ework-fork-mernst-branch-relevance-type-variable-upper-bound into javaparserutil-unit-tests
…ework-fork-mernst-branch-relevance-type-variable-upper-bound into javaparserutil-unit-tests
…ework-fork-mernst-branch-relevance-type-variable-upper-bound into javaparserutil-unit-tests
…ework-fork-mernst-branch-relevance-type-variable-upper-bound into javaparserutil-unit-tests
…ework-fork-mernst-branch-relevance-type-variable-upper-bound into javaparserutil-unit-tests
…ework-fork-mernst-branch-relevance-type-variable-upper-bound into javaparserutil-unit-tests
A class's member types are in scope in its body, but not in its header:
its annotations, its type parameter bounds, and its supertype names.
Likewise, the member types of an anonymous class are in scope only in
its body, not in the arguments to its constructor. `resolveTypeName`
now tests whether the name appears in the body, rather than testing only
whether it is one of the supertype names.
Other fixes:
* In `outer.new Inner() { ... }`, `Inner` is a member of the type of
`outer` rather than a name that is resolved in the scope of the
expression, so the anonymous class's supertype cannot be determined.
Return null (conservative) rather than resolving `Inner` lexically.
* An enum inherits the member type `EnumDesc` from its implicit
supertype `java.lang.Enum`. Search `java.lang.Enum` when the enum is
unnameable, rather than letting the name fall through to an enclosing
scope.
* Pass `typeElementCache` to `typeToTypeMirror`, which otherwise
allocated a fresh cache per call, so the field was never read.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`typeIsRelevant` called the 3-arg `JavaParserUtil.typeToTypeMirror`, which allocates a fresh cache per call, leaving `typeElementCache` unused. Pass the field to the 4-arg overload. In `extract-annotations` and `insert-annotations`, `AFU` silently became empty if the `cd`/`pwd` failed; fail there instead of at the eventual `java` call. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…ork-fork-mernst-branch-resolve-type-name-local-anonymous into resolve-type-name-member-scope
…-fork-mernst-branch-resolve-type-name-member-scope into resolve-member-type-inheritance
…k-fork-mernst-branch-resolve-member-type-inheritance into relevance-type-variable-upper-bound
…ework-fork-mernst-branch-relevance-type-variable-upper-bound into javaparserutil-unit-tests
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.
Part 9 of 9, splitting #8177 into reviewable pieces. Based on #8189. With this merged, the stack is equivalent to #8177, which can then be closed.
Until now
JavaParserUtil.resolveTypeNamewas exercised only indirectly, through theainfer-relevancegoal files, which cannot reach the cases that need types in more than one package.Add a unit test that runs the resolver directly against fixture sources in
superpkgandsubpkg, covering inherited member types, package-private members that are not inherited across packages, shadowing, and type-variable resolution.Test-only change; no production code is modified.
🤖 Generated with Claude Code