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

[KSP2] KSAnnotations with annotation properties with a default value always resolve to null #1843

Closed
ZacSweers opened this issue Apr 17, 2024 · 2 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@ZacSweers
Copy link
Contributor

Tested with 2.0.0-RC1-1.0.20

Given an annotation like so:

annotation class AnotherAnnotation(val input: String)

annotation class Example(
  val anotherAnnotation: AnotherAnnotation = AnotherAnnotation(""),
  val anotherAnnotationArray: Array<AnotherAnnotation> = [AnotherAnnotation("")],
)

@Example
class SomeAnnotatedClass

When reading the annotation instance off of SomeAnnotatedClass in a processor, the AnotherAnnotation default values are always null. I discovered this while preparing KotlinPoet for K2, with a repro available in this PR in the TestProcessorTest.removeDefaultValues test. If you breakpoint the isDefaultValue() check in KSAnnotation.toAnnotationSpec(), you can verify this behavior.

image
@ting-yuan ting-yuan added the bug Something isn't working label Apr 24, 2024
@ting-yuan ting-yuan added this to the 2.0 milestone Apr 24, 2024
@eygraber
Copy link

eygraber commented May 3, 2024

@neetopia
Copy link
Collaborator

neetopia commented May 7, 2024

this should be fixed by #1871 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants