False error: an anonymous subclass (new Anon() {}) does not get the state of the constructor it calls
メンテナーはふだん 2 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
Start by reading RefinementTypeChecker.visitCtNewClass and comparing it with visitCtConstructorCall, then inspect AuxStateHandler.onlySuperCall and delegatedConstructorState. Use the minimal reproducer in the issue to verify the behavior; it is done when the anonymous subclass with no instance or field initializer inherits the constructor's ready state and verification passes.
索引モデルが issue の本文から書いたものです。
説明
Impact: an object created as an anonymous subclass (new Anon() {}) has an unknown state, so the first state-refined call on it is a false error. The hint then suggests the very constructor that was called.
Minimal reproducer
import liquidjava.specification.StateRefinement;
import liquidjava.specification.StateSet;
@StateSet({"fresh", "ready"})
public abstract class Anon {
@StateRefinement(to = "ready(this)")
public Anon() {}
@StateRefinement(from = "ready(this)", to = "fresh(this)")
public void use() {}
static void ok() {
Anon a = new Anon() {};
a.use(); // the constructor made a ready
}
}
Expected: Correct! Passed Verification.; the anonymous class has no initializer, so a is in the state Anon() gives (ready).
Actual (main @ 0053074e):
State Refinement Error: found true but expected ready(a⁶)
12 | static void ok() {
13 | Anon a = new Anon() {};
14 | a.use(); // the constructor made a ready
| ^^^^^^^^
15 | }
16 | }
Hints:
- The state of a is unknown here. To get it to ready, use: new Anon()
Control: with a non-abstract Anon and Anon a = new Anon();, it verifies.
Cause. RefinementTypeChecker.visitCtNewClass only calls super.visitCtNewClass. Unlike visitCtConstructorCall, it never calls mfc.getConstructorInvocationRefinements, so the super constructor's to state is not applied. AuxStateHandler.delegatedConstructorState also returns empty for every CtNewClass, because the anonymous body may change the state. Applying the super constructor's state when the anonymous body has no instance initializer or field initializer (the same condition AuxStateHandler.onlySuperCall uses) would fix it.
🤖 Generated with Claude Code
- 主要言語
- Java
- スター
- 71
- フォーク
- 37
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 46
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
liquid-java/liquidjava のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
liquid-java/liquidjava#443 ·
メンテナーはふだん 2 日以内に返信
-
bug real-world-finding
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
liquid-java/liquidjava#395 ·
メンテナーはふだん 2 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
liquid-java/liquidjava#373 ·
メンテナーはふだん 2 日以内に返信
-
bug error messages
難易度 4/5 3〜5日 初心者へのやさしさ 52/100
liquid-java/liquidjava#471 ·
メンテナーはふだん 2 日以内に返信
-
bug error messages
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
liquid-java/liquidjava#469 ·
メンテナーはふだん 2 日以内に返信
liquid-java/liquidjava の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
Dans-Plugins/Medieval-Roleplay-Engine#396 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 6 日以内に返信
-
type: dependency-upgrade
難易度 1/5 1時間未満 初心者へのやさしさ 70/100
spring-projects/spring-session#4156 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
quarkiverse/quarkus-langchain4j#3127 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
HotswapProjects/HotswapAgent#688 ·