Formatting issue for annotated type parameter
- Dominant language
- Java
- Stars
- 5.6k
- Forks
- 559
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 34
Description
Given
```kotlin
internal object IntSerializer : KSerializer {
override val descriptor: SerialDescriptor
get() = PrimitiveSerialDescriptor(IntSerializer::class.qualifiedName!!, PrimitiveKind.STRING)
override fun serialize(encoder: Encoder, value: Int) {
encoder.encodeString(value.toHexString())
}
override fun deserialize(decoder: Decoder): Int = 0
}
```
The following expression
```kotlin
internal data class Foo(val bar: List>)
```
after running `./gradlew spotlessApply`, it is reformatted to
```kotlin
internal data class Foo(
val bar: List<
Pair<
@Serializable(IntSerializer::class)
Int,
String,
>,
>,
)
```
even though line max len is not exceeded, no matter how I split this.
Contributor guide
Research direction
Reproduce the issue with the nested Kotlin type-parameter example by running ./gradlew spotlessApply. Trace the Kotlin formatting path that handles @Serializable annotations inside nested Pair and List types. Done means the formatter respects the line-length limit and does not introduce the unnecessary expansion shown in the report.
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
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 66/100