typeArguments returns an empty list
- Dominant language
- Kotlin
- Stars
- 3.5k
- Forks
- 415
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 53
Description
In my library I need to inspect generic type arguments from an annotation.
Until version `2.0.21-1.0.28` this worked fine, but starting with version `2.2.0-*` it seems broken.
**Example**
```kotlin
private fun associateWithFor(item: KSAnnotation): List {
if (item.annotationType.toString() == MapConvert::class.simpleName) {
return item.annotationType.element!!
.typeArguments
.take(2)
.map { it.type!!.resolve().toClassName() }
}
return emptyList()
}
```
**Annotation definition**
```kotlin
@Target(AnnotationTarget.PROPERTY)
@Retention(AnnotationRetention.SOURCE)
@Repeatable
annotation class MapConvert>(
val converter: KClass,
val name: String = ""
)
```
**Usage**
```kotlin
@MapConvert(
converter = JvmDestinationCostConverter::class
)
```
**Problem**
- On `2.0.21-1.0.28`: `item.annotationType.element!!.typeArguments` contains the expected generic arguments (SourceObject, JvmDestinationObject).
- On `2.2.0-*` (and newer): `item.annotationType.element!!.typeArguments` is always empty.
**Expected behavior**
Generic type arguments provided to an annotation should be accessible via `annotationType.element!!.typeArguments`, just like before.
Contributor guide
Assessment
This issue has not been assessed yet.