use the resolved value of const
arguments in propagated annotation arguments
#940
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 have a good deal of logic around parsing out the primitive values of
const
parameters, but that logic is not recursive. So, if aconst
references anotherconst
in its initializer, we wound up just copying the text of that initializer into the generated annotations, as though it's just a String. This problem was isolated to the PSI side of parsing, since the Descriptor APIs are able to parse out the final, primitive value. Our type resolution logic always defaults to the PSI models.Now, when we need to parse out the primitive values from a
PropertyReference
, we first try to resolve the Descriptor version with aPropertyDescriptor
. That isn't possible if the annotation is referencing aconst
property that was generated in the same round of compilation. In that event, the parsing will fall back to the PSI models. Anvil doesn't actually generate aconst
and then use it in an annotation, so this seems like a reasonable compromise.fixes #938