Skip to content

False error: @StateSet on an enum is ignored, so its states give "Ghost 'Mode.off' could not be found" #468

Open

Description

@CatarinaGamboa

Impact: an enum cannot have typestates: any @StateRefinement that uses a state of an enum's @StateSet fails.

Minimal reproducer

import liquidjava.specification.StateRefinement;
import liquidjava.specification.StateSet;

@StateSet({"off", "on"})
public enum Mode {
    A;

    @StateRefinement(from = "off(this)", to = "on(this)")
    public void start() {}
}

Expected: Correct! Passed Verification. (or, if typestates on enums are not supported, an error saying so at the @StateSet).

Actual (main @ 0053074):

Not Found Error: Ghost 'Mode.off' could not be found
 6 |     A;
 7 | 
 8 |     @StateRefinement(from = "off(this)", to = "on(this)")
   |                              ^^^^^^^^^
 9 |     public void start() {}
10 | }

Without the @StateRefinement, the enum verifies (Correct! Passed Verification.), so the @StateSet is silently ignored.

Cause. MethodsFirstChecker.visitCtEnum only registers the enum constants; unlike visitCtClass, it never calls handleStateSetsFromAnnotation (or the ghost and alias handling), so the states off/on are never created.

🤖 Generated with Claude Code

Activity

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 working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions