Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Formatting issue for annotated type parameter

Open
#3,040 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
66/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
kotlin
Domain
tooling

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.

Description

Given

  internal object IntSerializer : KSerializer<Int> {
    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

  internal data class Foo(val bar: List<Pair<@Serializable(IntSerializer::class) Int, String>>)

after running ./gradlew spotlessApply, it is reformatted to

  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.

Dominant language
Java
Stars
5.7k
Forks
560
Avg merge
1d 13h
Merged PRs (30d)
43

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from diffplug/spotless

All issues in diffplug/spotless

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.