Support for class Constants #207
Conversation
| if (!(exp instanceof GroupExpression)) { | ||
| exp = new GroupExpression(exp); | ||
| } | ||
| exp = resolveStaticFinalConstants(exp, element); |
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
|
@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 |
|
Can't we treat those as variables instead? That way we'll solve that for free. |
we can add a new expression with the equality instead of replacing it, is that what you mean? |
|
Yep, exactly, that way we can also expand them to their values in the simplification. |
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>
0e7bb44 to
faaeb06
Compare
| * ({@code Type.CONST == literalValue}) while preserving the symbolic name in the AST. {@code null} for user-defined | ||
| * enum constants and for unresolvable references. | ||
| */ | ||
| private Expression resolvedLiteral; |
There was a problem hiding this comment.
We keep the resolved value here instead of substituting it
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