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 c151570
Browse filesBrowse the repository at this point in the historyBrowse files
## Description
The previous approach to add state dependent on return values was
attached to the return refinements
```
@refinement("_ --> acceptCompression(this)")
boolean canWriteCompressed();
```
However, this is not a great mental model since we should change object
states only using `@StateRefinements`. Therefore, now we allow using
StateRefinemets for this, and fix previous bugs with the previous logic.
```
@StateRefinement(from = "start(this)",
to = "return ? acceptCompression(this) : start(this)")
boolean canWriteCompressed();
```
## Example
Now we can verify:
```
ImageWriteParam setCompressionPreferences() {
ImageWriteParam param = new ImageWriteParam(Locale.getDefault());
if (param.canWriteCompressed()) {
param.setCompressionMode(ImageWriteParam.MODE_DEFAULT);
param.setCompressionQuality(0.85f); // State Refinement Error
}
return param;
}
```
where before we would get an error because `param.canWriteCompressed()`
implied a state that was in conflict with the previous state assigned in
the constructor.
Added several tests for the feature.
## Type of change
- [x] Bug fix
- [x] New feature
- [ ] Documentation update
- [ ] Code refactoring
## Checklist
- [x] Added/updated tests under
`liquidjava-example/src/main/java/testSuite/` (`Correct*` / `Error*`)
- [x] `mvn test` passes locally
- [ ] Updated docs/README if behavior or API changed
---------
Co-authored-by: Ricardo Costa <rcosta.ms358@gmail.com>
Copy file name to clipboardExpand all lines: liquidjava-verifier/src/main/java/liquidjava/processor/refinement_checker/general_checkers/MethodsFunctionsChecker.java
Copy file name to clipboardExpand all lines: liquidjava-verifier/src/main/java/liquidjava/processor/refinement_checker/object_checkers/AuxStateHandler.java
0 commit comments