Adopt Kotlin collection literals across src and test - #120
Merged
Conversation
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>
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Enables the experimental Kotlin collection-literals feature (via the
-Xcollection-literalscompiler flag) and converts eligible call sites to[...]literal syntax acrosssrcandtest:emptyList()→[]listOf(...)→[...]mutableListOf(...)→[...], adding an explicitMutableList<T>type on the declaration so mutability is never inferred away191 conversions across 61 Kotlin files.
Notes & judgment calls
listOf()/mutableListOf(). (Content.kt had zero call sites anyway.)EmptyListDefaultTestleft as-is. It exists to verifyemptyList()'s own semantics (singleton identity, default-parameter behavior); rewriting its body to[]would leave test names asserting things aboutemptyList()while no longer calling it.TestSupport.formData()gains an explicitMutableListreturn type. It had an inferred return type and callers mutate the result (data += ...), so converting the body alone would have silently degradedMutableList→List.Any?-typedshouldBe) 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-literalsflag lives alongside the Dokka refactor inbuild.gradle.ktsand 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): cleanlintKotlinMain/lintKotlinTest+detekt: clean (both parse the new syntax)./gradlew check: 364 tests, 0 failures[...]inside a string or comment was ever altered.🤖 Generated with Claude Code