Skip to content

Don't add annotation if it doesn't have the correct @Target#259

Merged
Randgalt merged 1 commit intomasterfrom
jordanz/type-use-bug
Nov 5, 2025
Merged

Don't add annotation if it doesn't have the correct @Target#259
Randgalt merged 1 commit intomasterfrom
jordanz/type-use-bug

Conversation

@Randgalt
Copy link
Owner

@Randgalt Randgalt commented Nov 5, 2025

This is further refinement of the TypeUse annotation issue. In this case when we copy annotations from the record that target of the annotation will be different than ElementType.RECORD_COMPONENT or ElementType.TYPE_USE, etc. Ensure that the annotation has a compatible @Target when adding.

Added a test record for this as well provided by @facboy

Fixes #258

This is a further refinement of the `TypeUse` annotation issue. In this
case when we copy annotations from the record, the target of the annotation
will be different than `ElementType.RECORD_COMPONENT` or
`ElementType.TYPE_USE`, etc. Ensure that the annotation has a compatible
`@Target` when adding.

Added a test record for this as well provided by @facboy

Fixes #258
@Randgalt Randgalt force-pushed the jordanz/type-use-bug branch from 92d276c to 1ecb3a7 Compare November 5, 2025 09:46
@facboy
Copy link
Contributor

facboy commented Nov 5, 2025

i can see it fixes the compilation error. technically you can add the annotation, it just has to be added to the inner type, e.g. MyRecord.@Nullable MyEnum, not @Nullable MyRecord.MyEnum.

@Randgalt
Copy link
Owner Author

Randgalt commented Nov 5, 2025

technically you can add the annotation, it just has to be added to the inner type

I tried getting that to work in the previous PR and it never worked correctly. Let's go with this for now.

@Randgalt Randgalt merged commit b5a3b36 into master Nov 5, 2025
3 checks passed
@Randgalt Randgalt deleted the jordanz/type-use-bug branch November 5, 2025 11:11
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.

Incorrect generation of TYPE_USE annotations that appear on records

2 participants