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

Annotations can't see nested classes added by ASTTs #1474

Open
chrylis opened this issue Apr 18, 2023 · 6 comments
Open

Annotations can't see nested classes added by ASTTs #1474

chrylis opened this issue Apr 18, 2023 · 6 comments

Comments

@chrylis
Copy link

chrylis commented Apr 18, 2023

I'm aware this is a consequence of ASTT-phase limitations, but it would be nice if it worked, and the specific case might be relevant to any future updates in how ASTTs are processed.

I have an immutable class I would like to use as a DynamoDB immutable record. The @DynamoDbImmutable class annotation requires a Class builder parameter, so I added @Builder(builderClassName = 'Builder') to my record:

@Builder(builderClassName = 'Builder')
@DynamoDbImmutable(builder = MyRecord.Builder)
class MyRecord {}

This compiles correctly with groovyc, creating both MyRecord.class and MyRecord$Builder.class. However, compiling in Eclipse (even with a full batch, non-incremental build) results in a compilation error (Unresolved compilation problem and no $Builder.class present). This seems to be because the compiler (STC?) is attempting to resolve the parameter before the ASTT gets a chance to create it.

@eric-milles
Copy link
Member

eric-milles commented Apr 18, 2023 via email

@chrylis
Copy link
Author

chrylis commented Apr 18, 2023

Understood regarding the underlying sequence of events. I mentioned this case in case the "annotation exists in a scope technically outside the class" is a meaningful coverage case for any future enhancement.

@eric-milles
Copy link
Member

eric-milles commented Apr 18, 2023 via email

@chrylis
Copy link
Author

chrylis commented Apr 18, 2023

The transform is groovy.transform.builder.Builder, which runs during semantic analysis. Unfortunately, a quick-and-dirty special-cased stub wouldn't be practical because it has a number of naming options and even non-sealed pluggable strategies.

@eric-milles
Copy link
Member

eric-milles commented Apr 18, 2023 via email

@eric-milles
Copy link
Member

eric-milles commented Apr 18, 2023 via email

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

No branches or pull requests

2 participants