You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
False error: an anonymous subclass (new Anon() {}) does not get the state of the constructor it calls #470
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
importliquidjava.specification.StateRefinement;
importliquidjava.specification.StateSet;
@StateSet({"fresh", "ready"})
publicabstractclassAnon {
@StateRefinement(to = "ready(this)")
publicAnon() {}
@StateRefinement(from = "ready(this)", to = "fresh(this)")
publicvoiduse() {}
staticvoidok() {
Anona = newAnon() {};
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).
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.
Activity