Repository navigation
Treat instanceof as an unknown boolean - #359
Merged
Merged
Conversation
Fixes #335. instanceof had no operator in the refinement language, so any `if (x instanceof T)` crashed with a NullPointerException. It is now a fresh boolean, as null comparisons already are: both branches stay reachable and verification continues. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CatarinaGamboa
force-pushed
the
fix/335-instanceof
branch
from
October 7, 2026 11:49
fc9dbdf to
caf2c67
Compare
rcosta358
approved these changes
Oct 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #335.
Problem
instanceofhas no counterpart in the refinement language, sogetOperatorFromKindreturned null for it and anyif (o instanceof String)crashed withCannot invoke "String.hashCode()" because "<local1>" is null, even in a file without refinements.Change
OperationsCheckertreatsinstanceofthe way it already treats comparisons withnull: the result is a fresh, unconstrained boolean (isUntranslatablecovers both, in the binary-operator and the assignment paths). Both branches stay reachable, so nothing is assumed from the test.Tests
CorrectInstanceof:instanceofin anif, bound to a boolean local and combined with&&, and negated inside||. Crashed on main, now passes.ErrorInstanceof: a refinement violation inside aninstanceofbranch is reported (crashed on main).o instanceof String s && !s.isEmpty()) also verifies.mvn testpasses.🤖 Generated with Claude Code