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 2e8d227
Browse filesBrowse the repository at this point in the historyBrowse files
Apply external class specs to user subclasses (#354)
Fixes#353.
## Problem
An external spec (`@ExternalRefinementsFor("java.lang.Throwable")`) did
not reach user subclasses: calling `initCause` on a custom
`RuntimeException` subclass crashed with `Sort mismatch at argument #1
for function java.lang.Throwable.state1 … supplied sort is
AppException`.
## Example
```java
class AppException extends RuntimeException {
AppException(String message, Throwable cause) { super(message, cause); }
}
AppException e = new AppException("operation failed", underlying);
e.initCause(detail); // now: State Refinement Error, found withThrowable(e) but expected noThrowable(e)
```
With `super(message)` instead, the same `initCause` passes.
## Change
- `RefinedVariable.addSuperTypes` walks superclasses and interfaces
transitively.
- `AuxStateHandler`: a constructor whose first statement is `super(...)`
inherits the to-state of the super constructor's spec, with the super
arguments renamed to this constructor's parameters (or literals). If a
to-state uses an argument that cannot be named, it falls back to the
default state as before. The spec lookup walks up only through
`Exception`, `RuntimeException` and `Error`, whose constructors delegate
unchanged to `Throwable`; other JDK subclasses are not assumed to (e.g.
`ClassNotFoundException(String)` sets a null cause).
- `RefinementProcessor`: the first pass is split so all external specs
are registered before any user class is checked; before, the result
depended on the order of types in the package.
## Tests
- `testSuite/classes/throwable_subclass_error`: subclass built with
`super(message, cause)`, then `initCause`, gives a State Refinement
Error.
- `testSuite/classes/throwable_subclass_correct`: subclass built with
`super(message)`, then `initCause`, passes.
- `mvn test` passes.
🤖 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