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

Nested classes wipe the outer class's field refinements

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

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
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
java
Área
compilers

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

bug

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

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 liquid-java/liquidjava

Todos los issues de liquid-java/liquidjava

Issues similares

Más issues de Java

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.