Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Chiusa
#175 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
66/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
java
Ambito
backend

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Java
Stelle
1
Fork
1
Merge medio
1h 55m
PR unite (30g)
8

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di CodeLaser/maddi

Tutte le issue di CodeLaser/maddi

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.