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 default annotation KClass values for built-in types use java.lang.* versions #1948

Closed
ZacSweers opened this issue Jun 4, 2024 · 3 comments · Fixed by #1950
Closed
Assignees
Labels
bug Something isn't working
Milestone

Comments

@ZacSweers
Copy link
Contributor

Consider this example:

annotation class ExampleAnnotation(val value: KClass<*> = String::class)

@ExampleAnnotation(String::class)
class Example

In KSP2, the default value of value is a KSTypeImpl that points at java/lang/String while the KSAnnotation argument from the annotated Example class points at kotlin/String. This results in the types not being considered equal.

image image
@ZacSweers
Copy link
Contributor Author

This was tested on 2.0.0-1.0.22-SNAPSHOT today

@neetopia neetopia self-assigned this Jun 4, 2024
@neetopia neetopia added the bug Something isn't working label Jun 4, 2024
@neetopia neetopia added this to the 2.1 milestone Jun 4, 2024
@neetopia
Copy link
Contributor

neetopia commented Jun 4, 2024

can you share how you configure to run on snapshot? I tried to run your test locally with a local build and I got this error

e: file:///var/folders/l7/39bc4svn2g3b08k7jx3rsf1c00m1r6/T/junit6026606767842928735/ksp/sources/kotlin/test/TestSmokeTestClass.kt:20:29 Unresolved reference 'kotlin'.

@ZacSweers
Copy link
Contributor Author

Just pushed a branch with it to the mentioned PR above: square/kotlinpoet#1885

The test is TestProcessorTest.removeDefaultValues

You can breakpoint Annotations.kt at line 59 or the isDefaultValue function on line 83 to see what I linked in the screenshots

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

Successfully merging a pull request may close this issue.

2 participants