Support for class Constants #207
Open
CatarinaGamboa wants to merge 5 commits intomainfrom
Open
Conversation
Predicates can now use static final primitive/String constants like Integer.MAX_VALUE or javax.imageio.ImageWriteParam.MODE_DEFAULT directly inside @refinement strings. Resolution honors the surrounding source file's imports (single-type and on-demand). When resolution fails but the reference matches a class in a common JDK package, the verifier suggests the missing import in the error message. Refactors the previous Java-side field-read resolution into a single StaticConstants utility shared by both paths. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
CatarinaGamboa
commented
May 4, 2026
| if (!(exp instanceof GroupExpression)) { | ||
| exp = new GroupExpression(exp); | ||
| } | ||
| exp = resolveStaticFinalConstants(exp, element); |
Collaborator
Author
There was a problem hiding this comment.
Do we need to call this all the time?
it will just see if there are enums to resolve in a small expression, if there are no enums it doesnt do anything else, so its fine
Collaborator
Author
|
@rcosta358 I'm not sure how this affects error messages as it will appear directly with the value in the SMT, but there is no link between the var and its value so we might need a followup pr to handle that |
Collaborator
|
Can't we treat those as variables instead? That way we'll solve that for free. |
Collaborator
Author
we can add a new expression with the equality instead of replacing it, is that what you mean? |
Collaborator
|
Yep, exactly, that way we can also expand them to their values in the simplification. |
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.
We did not support using static final fields from classes in predicates or using the values in Java code.
For example, both these cases would not have been possible before, and now are acceptable