Description
Reading a field of an object whose class is declared later in the file does not pick up the field's refinement, so a correct program fails with a false "not enough information" error. Writes to such fields are handled by #314 (fixing #308); reads are not.
Minimal reproducer
import liquidjava.specification.Refinement;
public class ReadBefore {
private final Job job = new Job();
@Refinement("_ >= 0")
public int get() { return job.port; }
static class Job { @Refinement("_ >= 0") int port; }
}
Expected
Correct! Passed Verification.
Actual
Refinement Error: true is not a subtype of #ret² >= 0
5 | public int get() { return job.port; }
| ^^^^^^^^^^^^^^^^
--> Not enough information to prove the expected refinement. Add a refinement or condition to constrain it.
Moving Job above get makes it pass.
Cause
Fields enter the context only in the second pass (RefinementTypeChecker.visitCtField), in source order. When job.port is read, this#port is not in context yet, so visitCtFieldRead falls through to new Predicate() (no information).
Reproduced on main at fbfb4e2 (liquidjava-verifier 0.0.35), and on the #314 branch.
Description
Reading a field of an object whose class is declared later in the file does not pick up the field's refinement, so a correct program fails with a false "not enough information" error. Writes to such fields are handled by #314 (fixing #308); reads are not.
Minimal reproducer
Expected
Correct! Passed Verification.Actual
Moving
Jobabovegetmakes it pass.Cause
Fields enter the context only in the second pass (
RefinementTypeChecker.visitCtField), in source order. Whenjob.portis read,this#portis not in context yet, sovisitCtFieldReadfalls through tonew Predicate()(no information).Reproduced on
mainat fbfb4e2 (liquidjava-verifier 0.0.35), and on the #314 branch.