False error: state sets declared two levels up the hierarchy are not kept across a call

Aperta
#505 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
57/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
java

Direzione di ricerca

Read AuxStateHandler.getGhostStatesFor, which the issue identifies as collecting state sets only from a class, its immediate superclass and interfaces, and indexing them by simple class name. Trace its callers and tests for inherited state sets, then check a hierarchy with a grandparent declaration and two same-named classes in different packages. Done when all supertypes are collected by qualified declaring type and the example preserves unlocked(c) after open().

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug

Problem. Typestate lookups only see the state sets of a class and its immediate supertypes. A class two levels below the one declaring the sets loses them across a call.

// Grand.java
import liquidjava.specification.*;

@StateSet({"closed", "opened"})
@StateSet({"unlocked", "locked"})
class Grand {
    @StateRefinement(to = "closed(this) && unlocked(this)")
    public Grand() {}
}
// Parent.java
class Parent extends Grand {}
// Child.java
import liquidjava.specification.*;

public class Child extends Parent {
    @StateRefinement(from = "closed(this) && unlocked(this)", to = "opened(this)")
    public void open() {}

    @StateRefinement(from = "unlocked(this)")
    public void needsUnlocked() {}

    public static void main(String[] args) {
        Child c = new Child();
        c.open();
        c.needsUnlocked(); // lock set should be kept by open()
    }
}
State Refinement Error: found opened(c) but expected unlocked(c)

open() does not mention the lock set, so it should keep unlocked(c).

Cause. AuxStateHandler.getGhostStatesFor collects the class, its superclass and its interfaces, but not their supertypes. It also indexes by simple class name, so two classes with the same simple name in different packages share one lookup.

Fix. Collect the sets over all supertypes, by qualified declaring type.

Found while designing #502.

Lingua principale
Java
Stelle
73
Fork
38
Merge medio
12h 32m
PR unite (30g)
45

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di liquid-java/liquidjava

Tutte le issue di liquid-java/liquidjava

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.