`KSValueArgument.value` may return `List<*>`
- Dominant language
- Kotlin
- Stars
- 3.5k
- Forks
- 415
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 53
Description
The API specifies that `KSValueArgument.value` returns an `Array` of the above listed types, however, if an annotation is given in a Java file as `@Anno(args = [arg1, arg2, ...])`, then `[arg1, arg2, ...]` is returned as a `java.util.ArrayList<*>`. Thus, if you match on the result of `KSValueArgument.value` and match on any or all of the types declared in the documentation, there is a case where the match is non-exhaustive or rather where you never hit a valid branch.
https://github.com/google/ksp/blob/98e422e6b32ba2f060d4e2ff20f7552321c2b8c2/api/src/main/kotlin/com/google/devtools/ksp/symbol/KSValueArgument.kt#L55
The fix is to check for the `ArrayList<*>` type and convert it to a `kotlin.Array<*>` type.
Contributor guide
Research direction
Start with api/src/main/kotlin/com/google/devtools/ksp/symbol/KSValueArgument.kt around line 55 and reproduce the Java annotation case described in the issue. Trace where the list-valued argument is produced, then verify that the result is exposed as a Kotlin Array so matching against the documented types is exhaustive.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 62/100