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

Đang mở
#505 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
57/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
java
Lĩnh vực
compilers, testing-qa

Hướng nghiên cứu

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

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Java
Star
73
Fork
38
Merge trung bình
12 giờ 32 phút
Pull request đã merge (30 ngày)
45

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của liquid-java/liquidjava

Tất cả issue của liquid-java/liquidjava

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.