Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Java printer: arrow-switch case labels print static constants unqualified

Abierto
#156 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
68/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
java
Área
backend

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug

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.

Lenguaje dominante
Java
Estrellas
1
Forks
1
Merge medio
1 h 58 min
PR fusionados (30 d)
5

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de CodeLaser/maddi

Todos los issues de CodeLaser/maddi

Issues similares

Más issues de Java

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.