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 KClass properties with a default value always resolve to error types #1842

Closed
ZacSweers opened this issue Apr 17, 2024 · 2 comments
Labels
AA waiting for upstream fix duplicate This issue or pull request already exists
Milestone

Comments

@ZacSweers
Copy link
Contributor

Tested with 2.0.0-RC1-1.0.20

Given an annotation like so:

annotation class Example(
  val someClass: KClass<*> = String::class,
  val someClasses: Array<KClass<*>> = [String::class],
)

@Example
class SomeAnnotatedClass

When reading the annotation instance off of SomeAnnotatedClass in a processor, the String::class types are always error types. 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.

I've also confirmed this happens even if you add an explicit kotlin.String import. This also is the case for the String::class inside an array, which similarly resolves to an error type.

image
@ting-yuan ting-yuan added this to the 2.0 milestone Apr 24, 2024
@ting-yuan ting-yuan added duplicate This issue or pull request already exists AA waiting for upstream fix labels Apr 24, 2024
@ting-yuan
Copy link
Collaborator

Waiting for upstream fix in Analysis API: https://youtrack.jetbrains.com/issue/KT-61775. ETA is hopefully within a couple of weeks.

This is a special case of #1646

@neetopia
Copy link
Collaborator

neetopia commented May 7, 2024

fixed as of #1646

@neetopia neetopia closed this as completed May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AA waiting for upstream fix duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants