Skip to content

Adopt Kotlin collection literals across src and test - #120

Merged
pambrose merged 1 commit into
masterfrom
collection-literals
Jul 26, 2026
Merged

Adopt Kotlin collection literals across src and test#120
pambrose merged 1 commit into
masterfrom
collection-literals

Conversation

@pambrose

Copy link
Copy Markdown
Contributor

Summary

Enables the experimental Kotlin collection-literals feature (via the -Xcollection-literals compiler flag) and converts eligible call sites to [...] literal syntax across src and test:

  • emptyList()[]
  • listOf(...)[...]
  • mutableListOf(...)[...], adding an explicit MutableList<T> type on the declaration so mutability is never inferred away

191 conversions across 61 Kotlin files.

Notes & judgment calls

  • Content DSL is unaffected. The flag applies to project sources only, not the JSR-223 script engine that evaluates content at runtime — DSL content files keep listOf()/mutableListOf(). (Content.kt had zero call sites anyway.)
  • EmptyListDefaultTest left as-is. It exists to verify emptyList()'s own semantics (singleton identity, default-parameter behavior); rewriting its body to [] would leave test names asserting things about emptyList() while no longer calling it.
  • TestSupport.formData() gains an explicit MutableList return type. It had an inferred return type and callers mutate the result (data += ...), so converting the body alone would have silently degraded MutableListList.
  • Ineligible sites skipped. Positions where the element type can't be inferred (e.g. Kotest's Any?-typed shouldBe) are correctly left untouched — the compiler is the authority.

Scope note

This branch also carries the pre-existing, already-uncommitted toolchain bumps that were in the working tree (Kotlin 2.4.10, kotlinter 5.6.0, utils 3.2.0, and the root Dokka config refactor). The -Xcollection-literals flag lives alongside the Dokka refactor in build.gradle.kts and can't be cleanly split at the file level, and the green build was verified against this exact combination.

Verification

  • compileKotlin / compileTestKotlin (forced --rerun-tasks): clean
  • lintKotlinMain / lintKotlinTest + detekt: clean (both parse the new syntax)
  • ./gradlew check: 364 tests, 0 failures
  • A custom Kotlin lexer audited every changed file: the set of string literals and comments is byte-identical to the base — no [...] inside a string or comment was ever altered.

🤖 Generated with Claude Code

Enable the experimental collection-literals feature via the -Xcollection-literals
compiler flag and convert eligible call sites to `[...]` literal syntax:

- emptyList()      -> []
- listOf(...)      -> [...]
- mutableListOf(...) -> [...], adding an explicit MutableList<T> type on the
  declaration so mutability is never inferred away

191 conversions across 61 Kotlin files. Content DSL sources evaluated by the
JSR-223 script engine are unaffected (the flag applies to project sources only),
and EmptyListDefaultTest is left as-is since it verifies emptyList()'s own
semantics.

TestSupport.formData() gains an explicit MutableList return type: it had an
inferred return type and callers mutate the result, so converting the body alone
would have silently degraded MutableList to List.

Also picks up the pre-existing, already-uncommitted toolchain bumps in the tree
(Kotlin 2.4.10, kotlinter 5.6.0, utils 3.2.0, and the root Dokka config
refactor), since the collection-literals flag lives alongside them in
build.gradle.kts and the build/lint/test run was verified against this exact
combination.

Verified: compileKotlin/compileTestKotlin, lintKotlinMain/Test, detekt, and the
full `check` suite (364 tests, 0 failures).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@pambrose
pambrose merged commit c3be6ee into master Jul 26, 2026
4 checks passed
@pambrose
pambrose deleted the collection-literals branch July 26, 2026 06:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant