Skip to content

Fix RemoveUnusedImports for inherited nested types#8091

Open
sakshichitnis27 wants to merge 1 commit into
openrewrite:mainfrom
sakshichitnis27:fix/7569-inherited-nested-static-import
Open

Fix RemoveUnusedImports for inherited nested types#8091
sakshichitnis27 wants to merge 1 commit into
openrewrite:mainfrom
sakshichitnis27:fix/7569-inherited-nested-static-import

Conversation

@sakshichitnis27

Copy link
Copy Markdown
Contributor

Preserves required static imports when a nested type is inherited through a superclass or implemented interface.

RemoveUnusedImports now considers the target type's inheritance hierarchy when determining whether a statically imported nested type is used. Named imports match only the requested nested type, while wildcard imports continue to consider all applicable nested types.

Added regression coverage for importing UserAccountDataAuth through FakeUserAccountClient, where the nested type is declared by the implemented UserAccountClient interface.

Tested with:

./gradlew licenseFormat

./gradlew :rewrite-java-test:test --tests org.openrewrite.java.RemoveUnusedImportsTest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

RemoveUnusedImports removes required static import for inherited nested type

1 participant