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

Aberta
#505 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
57/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
java
Domínio
compilers, testing-qa

Direção de pesquisa

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().

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.

Linguagem predominante
Java
Estrelas
73
Forks
38
Merge médio
12h 32min
PRs com merge (30d)
45

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de liquid-java/liquidjava

Todas as issues de liquid-java/liquidjava

Issues semelhantes

Mais issues de Java

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.