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

Offen
#468 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
68/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
java
Bereich
compilers

Rechercherichtung

Start by reading MethodsFirstChecker.visitCtEnum and comparing it with visitCtClass, especially the state-set, ghost, and alias handling mentioned in the issue. Run the minimal reproducer to confirm the failure; done means enum states are recognized and verification passes, or an explicit unsupported-feature error is reported at @StateSet.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

bug

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 @ 0053074e):

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

Vorherrschende Sprache
Java
Sterne
73
Forks
38
Ø Merge
12 Std. 32 Min.
Gemergte PRs (30 T.)
45

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus liquid-java/liquidjava

Alle Issues in liquid-java/liquidjava

Ähnliche Issues

Weitere Issues zu Java

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.