Repository navigation
Commit 321a732
Check typestate calls made directly on a constructor call (#361)
Fixes #336.
## Problem
`new Token(1).use()` passed although `Token(int)` leaves the object in
`used` and `use()` requires `fresh`; the same call through a local was
reported. `prepareInvocationTarget` only knew variable reads and targets
that already had an instance, so a constructor-call receiver had none
and `checkTargetChanges` skipped it. Real code does this often (`new
ServerSocket(port).accept()`, `new IOException(msg).initCause(e)`).
## Change
`AuxStateHandler.prepareInvocationTarget`: when the target is a
constructor call carrying its state (the constructor's to-state, or the
class's default state, as `getConstructorInvocationRefinements` already
records), it creates a fresh variable instance in that state, records
the type's supertypes on it (so a spec on a supertype applies), and
makes it the invocation's target. The usual from-state check and
transition then apply.
## Tests
- `ErrorConstructorReceiver`: `new ErrorReceiverToken(1).use()` gives
`found used(#fresh) but expected fresh(#fresh)`; passed on main.
- `CorrectConstructorReceiver`: `new …().use()` and `new …(1).report()`
pass.
- `mvn test` passes.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>1 parent 2e8d227 commit 321a732
3 files changed
Lines changed: 62 additions & 0 deletions
File tree
- liquidjava-example/src/main/java/testSuite
- liquidjava-verifier/src/main/java/liquidjava/processor/refinement_checker/object_checkers
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
719 | 719 | | |
720 | 720 | | |
721 | 721 | | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
722 | 733 | | |
723 | 734 | | |
724 | 735 | | |
| |||
0 commit comments