GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Nested classes wipe the outer class's field refinements · Issue #317 · liquid-java/liquidjava

Nested classes wipe the outer class's field refinements #317

New issue
Copy link
New issue
Copy link
Closed
#326
Closed
Nested classes wipe the outer class's field refinements#317
#326
Copy link
Labels
bugSomething isn't workingSomething isn't working

Description

@CatarinaGamboa
CatarinaGamboa
opened on Oct 2, 2026
Issue body actions

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 fbfb4e2 (liquidjava-verifier 0.0.35).

Activity

  1. CatarinaGamboa
    added
    bugSomething isn't workingSomething isn't working
    on Oct 2, 2026
  2. CatarinaGamboa
    added a parent issue on Oct 2, 2026
    • Handle refinements in nested classes #315
  3. rcosta358
    linked a pull request that will close this issuePreserve outer field refinements across nested classes #326on Oct 3, 2026
  4. rcosta358
    closed this as completedin #326on Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.