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

未关闭
#505 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
57/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
java

调研方向

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

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
Java
星标
73
派生
38
平均合并
12 小时 32 分钟
30 天内合并 PR
45

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

liquid-java/liquidjava 的其他 Issue

查看 liquid-java/liquidjava 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。