Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix modelling of array types for annotation processing #294

Closed
wants to merge 0 commits into from

Conversation

copybara-service[bot]
Copy link

Fix modelling of array types for annotation processing

A @C int @A [] @B [] is an '@A array of @B arrays of @C ints'. Turbine was parsing that example as (ArrayType @B (ArrayType @A (PrimitiveType @C int))), and then reversing the list of element types to compute the type path for the annotations in the output, and producing correct class files. The difference was still visible to the annotation processing API, and the wrong type annotations were showing up on ArrayType#getComponentType for multi-dimensional arrays.

This change fixes the bug by parsing the above example as (ArrayType @A (ArrayType @B (PrimitiveType @C int))). This requires reversing the list when pretty-printing the AST node, but simplifies computation of type_paths, and makes the right annotations show up on ArrayType#getComponentType.

This also simplifies parsing logic, the handling of trailing 'c-style' dimension
specifiers can now be handled by the same logic that parses regular dimension
specifiers.

Some combinations of multi-variable declarations and c-style arrays still
disagree with javac, which has known bugs in that area.

Finally, the integration test being added here for type annotations and
annotation processing will be generalized to also exercise type annotations
read from bytecode, to test the fix for b/307310010.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants