Fields with the same name in different classes collide
维护者通常 2 天内回复
还没有人认领这个 Issue。
评估
调研方向
Reproduce the failure with the minimal Collision example, then inspect field handling in OperationsChecker and RefinementTypeChecker.visitCtFieldRead. Trace how field reads and writes are keyed in the context, including the declaring class and target expression. Done means the example verifies successfully and similarly named fields retain their distinct refinements.
由索引模型根据 Issue 内容生成。
描述
Description
Fields are keyed in the context by name only (this#<name>), whatever class owns them and whatever the target expression is. Two fields with the same name in different classes (e.g. an outer class and a nested class) are treated as the same variable, so one is checked against the other's refinement.
Minimal reproducer
import liquidjava.specification.Refinement;
public class Collision {
@Refinement("_ < 0") int port = -1;
private final Job job = new Job();
public void send() { job.port = 5; }
static class Job { @Refinement("_ >= 0") int port; }
}
Expected
Correct! Passed Verification. (Job.port is _ >= 0.)
Actual
Refinement Error: this#port⁴ == 5 is not a subtype of this#port⁴ < 0
5 | public void send() { job.port = 5; }
| ^^^^^^^^^^^^^
The write to job.port is checked against Collision.port's refinement.
Cause
Field reads and writes use String.format(Formats.THIS, fieldName) (e.g. OperationsChecker, RefinementTypeChecker.visitCtFieldRead), with no owning class or target object. A fix would need to key fields by their declaring type, and ideally separate instances (this.port vs job.port).
Reproduced on main at fbfb4e23 (liquidjava-verifier 0.0.35).
- 主要语言
- Java
- 星标
- 67
- 派生
- 36
- 平均合并
- 4 天 17 小时
- 30 天内合并 PR
- 7
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
liquid-java/liquidjava 的其他 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
liquid-java/liquidjava#321 ·
维护者通常 2 天内回复
-
难度 4/5 3-5 天 新手友好度 68/100
liquid-java/liquidjava#323 ·
维护者通常 2 天内回复
-
bug
难度 3/5 1-2 天 新手友好度 76/100
liquid-java/liquidjava#322 ·
维护者通常 2 天内回复
-
bug
难度 4/5 3-5 天 新手友好度 55/100
liquid-java/liquidjava#317 ·
维护者通常 2 天内回复
-
bug
难度 4/5 3-5 天 新手友好度 62/100
liquid-java/liquidjava#316 ·
维护者通常 2 天内回复
查看 liquid-java/liquidjava 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 65/100
aoqia194/leaf-loader#19 ·
-
难度 2/5 1-3 小时 新手友好度 84/100
apache/streampark#4521 ·
-
0 - Backlog 1 - Ready documentation good first issue help wanted
难度 2/5 1-3 小时 新手友好度 78/100
-
cbor
难度 2/5 1-3 小时 新手友好度 84/100
FasterXML/jackson-dataformats-binary#844 ·
维护者通常 1 天内回复
-
Issue: Bug
难度 2/5 1-3 小时 新手友好度 82/100
OpenAPITools/openapi-generator#25107 ·
维护者通常 1 天内回复