In-source return refinement `_ == true --> s(this)` binds `this` to the return value (Argument Mismatch)

Aberta
#442 1 comentário 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
1-2 dias
Facilidade para iniciantes
55/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
java
Domínio
backend, testing-qa

Direção de pesquisa

Start with the in-source verifier path for @Refinement return clauses and compare how it binds this with the external-spec path. Run the one-file reproducer from the issue and confirm the boolean versus Edit argument mismatch; use the stated external refinement example as a comparison. Done when the in-source example verifies and the external example continues to verify.

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

Descrição

bug

A boolean method that reveals a state when it returns true, @Refinement("_ == true --> b(this)"), fails when the class is annotated in its own source. The same form verifies in an @ExternalRefinementsFor spec.

Reproducer (one file; run the verifier on it):

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

@StateSet({"a", "b"})
class Edit {
    @StateRefinement(to = "a(this)")
    public Edit() {}

    @StateRefinement(to = "b(this)")
    public void finish() {}

    @Refinement("_ == true --> b(this)")
    public boolean isDone() { return true; }

    @StateRefinement(from = "b(this)")
    public void needsB() {}
}

public class Main {
    static void use(Edit e) {
        if (e.isDone()) e.needsB();   // a true answer says b
    }
    public static void main(String[] args) { Edit e = new Edit(); e.finish(); use(e); }
}

Found on main @ f7f366c (also on 1a506fe):

Argument Mismatch Error: Argument '#ret_6' and its respective parameter of ghost 'Edit.state1' types are incompatible: expected Edit, got boolean
19 |     public boolean isDone() { return true; }

this in the return refinement seems to be bound to the return value (#ret_6) instead of the receiver.

Expected: the program verifies, as it does when the same refinements are written in an external spec. For example, this one verifies:

@ExternalRefinementsFor("javax.swing.undo.AbstractUndoableEdit")
@StateSet({"done", "undone"})
public interface EditRefinements {
    @StateRefinement(to = "done(this)") void AbstractUndoableEdit();
    @Refinement("_ == true --> done(this)") boolean canUndo();
    @StateRefinement(from = "done(this)", to = "undone(this)") void undo();
}
// client: static void use(AbstractUndoableEdit e) { if (e.canUndo()) e.undo(); }

Found while cataloguing spec forms for co-specification; the reproducers are probes V11 (in-source) and V21 (external) there. Low priority: external specs, the main use, work.

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.