Java printer: in a local class, a line comment before a field swallows the field
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 58/100
Direzione di ricerca
Start from the round trip described in the issue: parse a local class with a line comment before a field, then run JavaInspector.print2 with Formatter2Impl. Find where the printer emits the comment and the following field for class bodies, and check why local classes take a different path from member classes, which print correctly. Done when the local-class example prints the comment on its own line and the field stays intact and compilable, and the member-class output is unchanged.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem
In a local class (a class declared inside a method body), a line comment before a field is printed on the same line as the field. The field becomes part of the comment, and the class no longer compiles: every use of the field fails with "cannot find symbol".
int local(List<int[]> in) {
class Entry {
public final int a;
// TODO: a comment before a field
public final List<int[]> b;
Entry(int a, List<int[]> b) { this.a = a; this.b = new ArrayList<>(b); }
}
return new Entry(1, in).a;
}
prints as
class Entry {
final int a;
// TODO: a comment before a field final List<int []> b;
Entry(int a, List<int []> b) { this.a = a; this.b = new ArrayList<>(b); }
}
The same class declared as a nested (member) class prints correctly, with the comment on its own line.
Expected
A line comment always ends its line, wherever it is.
Seen on
A round trip (parse, then JavaInspector.print2 with Formatter2Impl) on maddi 0.9.5-alpha.5. On real code: fernflower's FinallyProcessor, whose local class BlockStackEntry has // TODO: correct handling (merging) of multiple paths before the field lstStoreVars. Possibly related to #49 (comment positions), but there's no moved code here.
- Lingua principale
- Java
- Stelle
- 1
- Fork
- 1
- Merge medio
- 2h 51m
- PR unite (30g)
- 3
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di CodeLaser/maddi
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
build/ci good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
-
Java printer: drops the qualifier a call needs (explicit type arguments, a method named yield)Apertabug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 65/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 28/100
Tutte le issue di CodeLaser/maddi
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
sqlcipher/sqlcipher-android#97 · 1 commento ·
-
bug IIIF interoperability
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
Netcracker/qubership-integration-platform#1046 ·
I maintainer di solito rispondono entro 2 giorni
-
`check_java_version()` fails when Java path contains spaces (Windows / Git Bash, `C:\Program Files`)Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100