Java printer: an Outer.this qualifier on a call is dropped, so the call binds to the inner class's method
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 66/100
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- Java
- Sterne
- 1
- Forks
- 1
- Ø Merge
- 1 Std. 55 Min.
- Gemergte PRs (30 T.)
- 8
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus CodeLaser/maddi
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
CodeLaser/maddi#166 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
build/ci good first issue
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 58/100
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 67/100
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 68/100
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in CodeLaser/maddi
Ähnliche Issues
-
pending:code-area pending:issue-category to-triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
Maintainer antworten meist innerhalb von 1 Tag
-
area:core bug priority:p2
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
aomarai/minecraft-mcp#247 ·
Maintainer antworten meist innerhalb von 1 Tag
-
help wanted
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
antonyrag/ragleap-core#1062 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
projectnessie/nessie#13256 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
Vakore/ZappierGames#232 ·