Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

Fields with the same name in different classes collide

Aberta
#318 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 2 dias

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
52/100
Tipo de issue
Bug
Clareza
Razoavelmente clara
Status de atividade
Ativa
Stack de tecnologia
java
Domínio
compilers

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

bug

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

Linguagem predominante
Java
Estrelas
67
Forks
36
Merge médio
4d 17h
PRs com merge (30d)
7

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de liquid-java/liquidjava

Todas as issues de liquid-java/liquidjava

Issues semelhantes

Mais issues de Java

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.