Skip to content

Don't treat an uninherited member type as inherited - #8187

Closed
mernst wants to merge 9 commits into
resolve-type-name-member-scopefrom
resolve-member-type-inheritance
Closed

mernst wants to merge 9 commits into
resolve-type-name-member-scopefrom
resolve-member-type-inheritance

Conversation

@mernst

@mernst mernst commented Sep 16, 2026 •

Copy link
Copy Markdown
Member

Based on #8186. With this merged, the stack is equivalent to #8177, which can then be closed.

resolveMemberType returned any non-private member type that it found in a supertype. Two errors:

  • A package-private member type is inherited only within its own package, so a package-private member type of a supertype in a different package was wrongly returned.
  • A declaration hides what its declaring type would otherwise inherit even when the declaration itself is not inherited, so the search must not continue past it into that type's supertypes.

Either error made annotationIsRelevant ask about the wrong type, which could discard a relevant annotation.

Adds PackagePrivateNotInherited plus an otherpackage subdirectory -- the first ainfer-relevance test input in a named package -- and generalizes AinferRelevanceAjavaGenerationTest to name a goal file after the class's fully-qualified name.

🤖 Generated with Claude Code

`resolveMemberType` returned any non-private member type that it found in a
supertype.  A package-private member type is inherited only within its own
package, so a package-private member type of a supertype in a different
package was wrongly returned.  Also, a declaration hides what its declaring
type would otherwise inherit even when the declaration itself is not
inherited, so the search must not continue past it into that type's
supertypes.

Either error made `annotationIsRelevant` ask about the wrong type, which
could discard a relevant annotation.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
mernst and others added 8 commits September 16, 2026 12:54
…-fork-mernst-branch-resolve-type-name-member-scope into resolve-member-type-inheritance
…-fork-mernst-branch-resolve-type-name-member-scope into resolve-member-type-inheritance
…-fork-mernst-branch-resolve-type-name-member-scope into resolve-member-type-inheritance
…-fork-mernst-branch-resolve-type-name-member-scope into resolve-member-type-inheritance
…-fork-mernst-branch-resolve-type-name-member-scope into resolve-member-type-inheritance
…-fork-mernst-branch-resolve-type-name-member-scope into resolve-member-type-inheritance
…-fork-mernst-branch-resolve-type-name-member-scope into resolve-member-type-inheritance
`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>
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

Successfully merging this pull request may close these issues.

1 participant