Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

shortenFullyQualifiedTypes can change type resolution for inherited nested types

クローズ
#3,117 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@kalayciburak がすでに取り組んでいます。

2026年10月1日 から。

  • #3124 @kalayciburak による — オープン

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
52/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
java
領域
tooling

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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
主要言語
Java
スター
5.7k
フォーク
563
平均マージ
2日 2時間
マージ済み PR(30日)
57

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

diffplug/spotless のほかの issue

diffplug/spotless の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。