Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

shortenFullyQualifiedTypes can change type resolution for inherited nested types

Fechada
#3,117 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

@kalayciburak já está trabalhando nisso.

Desde 1/10/2026.

  • #3124 de @kalayciburak — aberto

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
52/100
Tipo de issue
Bug
Clareza
Razoavelmente clara
Status de atividade
Ativa
Stack de tecnologia
java
Domínio
tooling

Direção de pesquisa

Start with the shortenFullyQualifiedTypes() implementation and reproduce the issue using the linked Gradle project and ./gradlew spotlessApply. Trace how inherited nested types affect shortening decisions, then verify that the qualified external.Type reference remains safe and the formatted project still compiles.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

Summary

shortenFullyQualifiedTypes can change the meaning of a qualified type when the simple name is also an inherited nested type.

The formatter avoids some collisions with types declared in the same compilation unit, but does not appear to account for member types inherited from a superclass or interface.

Reproducer

Spotless Gradle plugin 8.10.3, with shortenFullyQualifiedTypes() as the only configured Java step:

The complete Gradle project is available here:

https://gist.github.com/MattAlp/a50100bc9d712c470ded424c36e8f315

The reproducer contains:

  • Base, which declares nested type Type
  • Child, which extends Base
  • external.Type, which is referenced by fully qualified name

Before formatting, Child contains:

public static String use(external.Type value) {
    return value.externalOnly();
}

The project compiles successfully. After running:

./gradlew spotlessApply

Spotless adds import external.Type; and changes the code to:

public static String use(Type value) {
    return value.externalOnly();
}

The unqualified Type resolves to the inherited Base.Type, not external.Type. Compilation then fails:

cannot find symbol
  method externalOnly()
  location: variable value of type Type

Suggested behavior

Leave a qualified reference alone when its simple name can resolve to an inherited member type. If this cannot be determined without a classpath, the conservative behavior should be to leave the qualification intact.

Related work

This appears related to:

  • #3033 — same-compilation-unit type collisions
  • #3031 — collisions with types declared in the same file
  • #3037 — preserving existing unqualified type resolution
Linguagem predominante
Java
Estrelas
5.7k
Forks
562
Merge médio
3d 2h
PRs com merge (30d)
30

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de diffplug/spotless

Todas as issues de diffplug/spotless

Issues semelhantes

Mais issues de Java

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.