False error: @StateSet on an enum is ignored, so its states give "Ghost 'Mode.off' could not be found"

Đang mở
#468 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ó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
68/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

Hướng nghiên cứu

Start by reading MethodsFirstChecker.visitCtEnum and comparing it with visitCtClass, especially the state-set, ghost, and alias handling mentioned in the issue. Run the minimal reproducer to confirm the failure; done means enum states are recognized and verification passes, or an explicit unsupported-feature error is reported at @StateSet.

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

Mô tả

bug

Impact: an enum cannot have typestates: any @StateRefinement that uses a state of an enum's @StateSet fails.

Minimal reproducer

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

@StateSet({"off", "on"})
public enum Mode {
    A;

    @StateRefinement(from = "off(this)", to = "on(this)")
    public void start() {}
}

Expected: Correct! Passed Verification. (or, if typestates on enums are not supported, an error saying so at the @StateSet).

Actual (main @ 0053074e):

Not Found Error: Ghost 'Mode.off' could not be found
 6 |     A;
 7 | 
 8 |     @StateRefinement(from = "off(this)", to = "on(this)")
   |                              ^^^^^^^^^
 9 |     public void start() {}
10 | }

Without the @StateRefinement, the enum verifies (Correct! Passed Verification.), so the @StateSet is silently ignored.

Cause. MethodsFirstChecker.visitCtEnum only registers the enum constants; unlike visitCtClass, it never calls handleStateSetsFromAnnotation (or the ghost and alias handling), so the states off/on are never created.

🤖 Generated with Claude Code

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.