Skip to content

shortenFullyQualifiedTypes: preserve unqualified type resolution - #3037

Open
maxandersen wants to merge 1 commit into
diffplug:mainfrom
maxandersen:3033-unqualified-type-collision
Open

shortenFullyQualifiedTypes: preserve unqualified type resolution#3037
maxandersen wants to merge 1 commit into
diffplug:mainfrom
maxandersen:3033-unqualified-type-collision

Conversation

@maxandersen

Copy link
Copy Markdown
Contributor

Fixes #3033.

When a compilation unit already uses an unqualified type name, adding an import
for a different fully qualified type with the same simple name can change what
the existing reference resolves to.

Collect unqualified type references and leave conflicting fully qualified
references unchanged, unless the target type is already explicitly or
implicitly imported.

Adds a regression test for a same-package RandomAccessFile extended by a
class that also references java.io.RandomAccessFile.

Tests

  • ./gradlew :testlib:test --tests com.diffplug.spotless.java.ShortenFullyQualifiedTypesStepTest
  • ./gradlew spotlessCheck

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.

shortenFullyQualifiedTypes produces uncompilable code when the simple name collides with a type in the same compilation unit

1 participant