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 annotations being not expected in the middle of an array type by java parser #22391

Conversation

fan-tom
Copy link
Contributor

@fan-tom fan-tom commented Jan 16, 2025

Closes #19642

Currently Java parser doesn't expect annotation between type name and square brackets in an array type, or between pairs of square brackets in nested array types.

I added a call to corresponding parser method annotations when parsing array types.

I also changed an unnecessary var to val, as IDEA suggested.

@fan-tom fan-tom marked this pull request as ready for review January 17, 2025 09:35
@fan-tom

This comment was marked as resolved.

Copy link
Member

@hamzaremmal hamzaremmal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @fan-tom. thanks for contributing to Scala 3 🎉 . Your changes only covers half of the issue (type annotations on array). To fully close the linked issue, a fix for path selection has to be submitted. Would you like to try fixing it or should we take it from here ? Your changes for annotations on array types are correct and can be merged when all the requirements to close the issue are met.

@fan-tom
Copy link
Contributor Author

fan-tom commented Jan 20, 2025

Thanks @hamzaremmal

Would you like to try fixing it

Definitely, but I need inputs for that, like what's path selection. If possible, I'd like to get help writing a test case, from which I can unwind what and where exactly in code goes wrong. I tried to search for this term in https://dotty.epfl.ch/docs but got nothing

@fan-tom
Copy link
Contributor Author

fan-tom commented Jan 20, 2025

Oh, I just got that original issue speaks about such syntax Class.@TpeAnnot NestedClass

…ava parser

Java parser doesn't expect an annotation in the next types, while it should:
- `Object @my.Ann []`
- `Object @my.Ann [] @my.OtherAnn []`

closes scala#19642
@fan-tom
Copy link
Contributor Author

fan-tom commented Jan 20, 2025

@hamzaremmal hasn't path selection syntax been fixed in #21867? At least the MRE test from the original issue passes, without any additional fixes from my side. Seems issue and PR were not linked properly.

@fan-tom fan-tom force-pushed the bugfix/19642-java-parse-annottations-in-array-types branch from ed25fca to 9c971be Compare January 20, 2025 22:30
@fan-tom fan-tom requested a review from hamzaremmal January 20, 2025 22:31
@hamzaremmal
Copy link
Member

@hamzaremmal hasn't path selection syntax been fixed in #21867? At least the MRE test from the original issue passes, without any additional fixes from my side. Seems issue and PR were not linked properly.

Ah yes, it does

@hamzaremmal hamzaremmal merged commit 3ea209b into scala:main Jan 21, 2025
29 checks passed
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.

Cannot parse Java file with type annotations on array or path selection
2 participants