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
Commit 9c51147
Browse filesBrowse the repository at this point in the historyBrowse files
Check calls on a constructor call whose constructor has refined parameters (#407)
Follow-up to #361 (typestate calls made directly on a constructor call).
## Problem
A call made directly on `new T(args)` fails when the constructor
`T(args)` has refined parameters:
```java
Socket socket = new ServerSocket(8080).accept();
```
```
Argument Mismatch Error: Argument '#<init>_398' and its respective parameter of ghost
'java.net.ServerSocket.state1' types are incompatible: expected ServerSocket, got void
```
With refined parameters, the constructor call goes through
`applyReturnRefinement`, which sets the call's `TARGET` metadata to the
constructor's return-value instance (`#<init>_N`, typed `void`).
`prepareInvocationTarget` checked `TARGET` before the constructor-call
case, so it used that instance as the receiver. Constructors without
refined parameters (`new ServerSocket().accept()`) were not affected.
## Fix
- `prepareInvocationTarget` handles a constructor-call target before
falling back to `TARGET` metadata.
- The fresh receiver is stored under a new `Keys.RECEIVER` key on the
constructor call and reused when the same invocation is prepared again
(the target is prepared both for the parameter checks and for the state
change), so it is created once.
## Tests
- `CorrectConstructorReceiverRefinedArgument`: `new
Listener(8080).accept()` where `Listener(int)` has a refined parameter
and lands in `bound`. It failed before this change.
- `ErrorConstructorReceiverRefinedArgument`: the same constructor
followed by a call that needs `unbound` is reported.
- `mvn test`: 414 tests, 0 failures.
Found on a real fixed bug (a static page server whose fix was `new
ServerSocket(port).accept()`). We also checked 53 exercises built from
real OSS bugs: the results are identical to main's.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: liquidjava-verifier/src/main/java/liquidjava/processor/refinement_checker/object_checkers/AuxStateHandler.java
0 commit comments