KSAnnotation#arguments order changes if viewed from source vs dependency.
- Dominant language
- Kotlin
- Stars
- 3.5k
- Forks
- 415
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 53
Description
Consider a project with the following libraries, `:main -> :lib`, with the following sources:
```kotlin
// :main
@MyAnnotation(b = "b", a = "a")
class Main
// :lib
@MyAnnotation(b = "b", a = "a")
class Lib
// :my_annotation
annotation class MyAnnotation(
val a: String,
val b: String,
)
```
And a KSP processor defined as follows:
```kotlin
override fun process(resolver: Resolver): List {
fun printAnnotationValues(name: String) {
val declaration = resolver.getClassDeclarationByName(resolver.getKSNameFromString(name))!!
val annotation =
declaration.annotations.single {
it.annotationType.resolve().declaration.qualifiedName?.asString() == "MyAnnotation"
}
println("$name: ${annotation.arguments.map { it.name?.asString() }}")
}
printAnnotationValues("Lib")
printAnnotationValues("Main")
return listOf()
}
```
When processing `:main` we see the following output:
```
Lib: [a, b]
Main: [b, a]
```
In particular, processing a source vs class file we get different order of annotation values.
Contributor guide
Research direction
Start by reproducing the example through the KSP Resolver entry point, especially getClassDeclarationByName, declaration.annotations, and annotation.arguments for Main and Lib. Trace how annotation arguments are exposed for source declarations versus dependency class files, then verify that both cases report a consistent order.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100