Nested classes wipe the outer class's field refinements
Los mantenedores suelen responder en 2 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 55/100
Línea de trabajo
Start in RefinementTypeChecker.visitCtClass and MethodsFirstChecker.visitCtClass, focusing on how context.reinitializeContext() changes ctxVars while Spoon visits nested classes. Use the OuterWiped reproducer to verify that the outer field refinement remains available after Inner, while writes such as x = -1 are still rejected. Done means the reproducer passes verification without losing the existing write check.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Description
Entering a nested class resets the variable context, which wipes the outer class's fields. Any method of the outer class declared after a nested class loses the refinements of the outer class's own fields.
Minimal reproducer
import liquidjava.specification.Refinement;
public class OuterWiped {
@Refinement("_ > 0") int x = 1;
static class Inner { int y; }
@Refinement("_ > 0")
public int get() { return x; }
}
Expected
Correct! Passed Verification.
Actual
Refinement Error: true is not a subtype of #ret¹ > 0
6 | public int get() { return x; }
| ^^^^^^^^^
--> Not enough information to prove the expected refinement. Add a refinement or condition to constrain it.
Removing Inner (or moving it below get) makes it pass. Writes such as x = -1 are still rejected correctly, because the expected refinement is read from the field's annotation.
Cause
RefinementTypeChecker.visitCtClass (and MethodsFirstChecker.visitCtClass) call context.reinitializeContext(), which clears ctxVars. Spoon visits nested classes as children of the outer class, so visiting Inner clears this#x. The opposite also happens: the nested class's fields stay in the context after it returns. That leak is why declaring a nested class before its use works today (see #308).
Possible fix
When a class is entered, register all of its fields (and those of its nested types) before visiting any methods, and keep nested classes from clearing the enclosing class's context. This would probably also fix the read case above.
Reproduced on main at fbfb4e23 (liquidjava-verifier 0.0.35).
- Lenguaje dominante
- Java
- Estrellas
- 67
- Forks
- 36
- Merge medio
- 4 d 17 h
- PR fusionados (30 d)
- 7
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de liquid-java/liquidjava
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
liquid-java/liquidjava#321 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 4/5 3-5 días Aptitud para principiantes 68/100
liquid-java/liquidjava#323 ·
Los mantenedores suelen responder en 2 días
-
Soundness: a field of another class or object is read as this class's field with the same nameAbiertobug
Dificultad 3/5 1-2 días Aptitud para principiantes 76/100
liquid-java/liquidjava#322 ·
Los mantenedores suelen responder en 2 días
-
bug
Dificultad 4/5 3-5 días Aptitud para principiantes 52/100
liquid-java/liquidjava#318 ·
Los mantenedores suelen responder en 2 días
-
bug
Dificultad 4/5 3-5 días Aptitud para principiantes 62/100
liquid-java/liquidjava#316 ·
Los mantenedores suelen responder en 2 días
Todos los issues de liquid-java/liquidjava
Issues similares
-
Update license yearAbierto0 - Backlog 1 - Ready documentation good first issue help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
cbor
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
FasterXML/jackson-dataformats-binary#844 ·
Los mantenedores suelen responder en 1 día
-
improvement
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
apache/iceberg#18351 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
bug good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 90/100
repowise-dev/repowise#2945 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Interpolating settings.xml can lead to malformed XML when variable value contains double-hyphenAbiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
apache/maven#13321 · 1 comentario ·
Los mantenedores suelen responder en 1 día