Java printer: arrow-switch case labels print static constants unqualified
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
- 68/100
Direzione di ricerca
Start with SwitchEntryImpl.print and trace how it chooses qualification for arrow-switch case conditions; compare this with the surrounding qualification used for old-style switch labels. Check the printer tests for switch statements and expressions, then add coverage for a static constant from another class and an enum constant. Done means both arrow-switch forms preserve compilable qualification while enum labels remain valid.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
SwitchEntryImpl.print prints every case condition with QualificationImpl.SIMPLE_ONLY. That is right for an enum constant (Java requires the simple name there before Java 21), but wrong for a static constant of another type:
class Consts { static final int ONE = 1; }
class User {
int kind(int v) {
switch (v) {
case Consts.ONE -> { return 10; }
default -> { return 20; }
}
}
}
prints as case ONE -> ..., which does not compile in User (no ONE in scope). The same holds for a switch expression, which prints its entries the same way. Old-style switches print their labels with the surrounding qualification and are not affected.
Found when printing a method body into another class: the original text was case CodeConstants.GROUP_JUMP ->, the printed copy case GROUP_JUMP ->.
Suggested fix: use SIMPLE_ONLY only when the condition is a field reference to an enum constant of the selector's enum type, and print the other conditions with the given qualification.
- Lingua principale
- Java
- Stelle
- 1
- Fork
- 1
- Merge medio
- 1h 34m
- PR unite (30g)
- 7
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
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
build/ci good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 45/100
CodeLaser/maddi#165 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 40/100
CodeLaser/maddi#164 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di CodeLaser/maddi
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
ome/ome-codecs#48 ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
tonihele/OpenKeeper#672 ·
I maintainer di solito rispondono entro 4 giorni
-
Shaded google-api-client trust stores still include AAA Certificate Services (eMudhra CA compromise)Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
snowflakedb/snowflake-jdbc#2763 ·
-
MacFileUtils: FSPathMakeRef passes an int where the C function takes its FSRef output pointerAperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 79/100
java-native-access/jna#1746 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
ControlSystemStudio/phoebus#3983 ·
I maintainer di solito rispondono entro 2 giorni