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

Java printer: an Outer.this qualifier on a call is dropped, so the call binds to the inner class's method

オープン
#175 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

まだ誰も着手していません。

評価

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

調査の方向性

Start by tracing javaInspector.print2 and the Java call-printing logic; the issue gives no source file or test name. Reproduce the example and inspect the printed source to find where the Outer.this qualifier is lost. Done means the qualifier is retained when needed to resolve the call correctly, with a regression test showing the output compiles.

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

説明

bug

In an anonymous or inner class, a call qualified by the enclosing instance (Outer.this.m(..)) prints as a bare m(..). When the inner class has a method of the same name, the printed call means another method: it no longer compiles or, when the argument types fit, silently calls the wrong one.

package a.b;
import java.util.List;
abstract class X<T> {
    abstract void apply(StringBuilder b, T value);
    final X<List<T>> iterable() {
        return new X<List<T>>() {
            @Override
            void apply(StringBuilder b, List<T> values) {
                if (values == null) return;
                for (T value : values) {
                    X.this.apply(b, value);
                }
            }
        };
    }
}

javaInspector.print2(cu, null, javaInspector.importComputer(4, cu.sourceSet())) prints the loop as

for (T value : values) { apply(b, value); }

which resolves to the anonymous class's own apply(StringBuilder, List<T>), and javac rejects it. The qualifier has to stay when the simple name would find a member of a nearer class, as with an explicit Outer.this the source wrote.

Found re-parsing printed sources of retrofit (ParameterHandler.iterable() and array(): ParameterHandler.this.apply(builder, value)); the unit is dropped. Related to #106 (other qualifiers a call needs).

maddi 0.9.6-alpha.4.

主要言語
Java
スター
1
フォーク
1
平均マージ
1時間 55分
マージ済み PR(30日)
8

環境構築

はじめの一歩

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

CodeLaser/maddi のほかの issue

CodeLaser/maddi の issue をすべて見る

似ている issue

Java の issue をもっと見る

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

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