Repository navigation
Commit ef1603d
Treat instanceof as an unknown boolean (#359)
Fixes #335.
## Problem
`instanceof` has no counterpart in the refinement language, so
`getOperatorFromKind` returned null for it and any `if (o instanceof
String)` crashed with `Cannot invoke "String.hashCode()" because
"<local1>" is null`, even in a file without refinements.
## Change
`OperationsChecker` treats `instanceof` the way it already treats
comparisons with `null`: the result is a fresh, unconstrained boolean
(`isUntranslatable` covers both, in the binary-operator and the
assignment paths). Both branches stay reachable, so nothing is assumed
from the test.
## Tests
- `CorrectInstanceof`: `instanceof` in an `if`, bound to a boolean local
and combined with `&&`, and negated inside `||`. Crashed on main, now
passes.
- `ErrorInstanceof`: a refinement violation inside an `instanceof`
branch is reported (crashed on main).
- Pattern matching (`o instanceof String s && !s.isEmpty()`) also
verifies.
- `mvn test` passes.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>1 parent ffd51c6 commit ef1603d
3 files changed
Lines changed: 53 additions & 3 deletions
File tree
- liquidjava-example/src/main/java/testSuite
- liquidjava-verifier/src/main/java/liquidjava/processor/refinement_checker/general_checkers
Lines changed: 28 additions & 0 deletions
| 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 | + | |
| 27 | + | |
| 28 | + | |
Lines changed: 17 additions & 0 deletions
| 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 | + | |
Lines changed: 8 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | | - | |
86 | | - | |
| 85 | + | |
| 86 | + | |
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| |||
245 | 245 | | |
246 | 246 | | |
247 | 247 | | |
248 | | - | |
| 248 | + | |
249 | 249 | | |
250 | 250 | | |
251 | 251 | | |
| |||
336 | 336 | | |
337 | 337 | | |
338 | 338 | | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
339 | 344 | | |
340 | 345 | | |
341 | 346 | | |
| |||
0 commit comments