Skip to content

Upgrade Kotlin to 2.4.20-Beta2 - #237

Draft
vRallev wants to merge 5 commits into
mainfrom
ralf/kotlin-2.4.20-beta2
Draft

Upgrade Kotlin to 2.4.20-Beta2#237
vRallev wants to merge 5 commits into
mainfrom
ralf/kotlin-2.4.20-beta2

Conversation

@vRallev

@vRallev vRallev commented Jul 31, 2026

Copy link
Copy Markdown
Owner

Summary

  • Upgrade the main build from Kotlin 2.4.10 to 2.4.20-Beta2; leave the standalone blueprints unchanged.
  • Adapt the compiler plugin to the Kotlin 2.4.20 FIR, IR, and compiler-test APIs.
  • Generate App Platform's renderer, robot, and scoped Metro binding containers in IR through Metro's extension API.
  • Keep only cross-module contribution-discovery hints in FIR and explicitly run App Platform's declaration generation before Metro's IR graph transformation.
  • Update compiler goldens and generated JVM API snapshots for the new IR output.

Issues found

Metro 1.4.0 enables IR class generation with Kotlin 2.4.20-Beta2. App Platform's former FIR declaration generators are therefore not invoked, which removes its generated bindings.

Moving the containers to IR uncovered two additional constraints:

  1. Metro's FIR-hint option is coupled to IR class generation in its Gradle plugin, but Native and Wasm downstream compilations cannot discover package callables generated in IR. The build now leaves class generation in IR enabled while retaining FIR only for Metro's package-level contribution hints.
  2. On Kotlin/Native, Metro must see App Platform's generated containers before it transforms and merges the graph. The Gradle plugins now set that compiler-plugin order explicitly.

The generated contribution containers are implementation details and no longer appear as source-level declarations or in JVM API snapshots.

Validation

  • Full Android unit, iOS simulator, Desktop, Linux, and Wasm test matrix: 1,953 tasks passed.
  • All 57 compiler-plugin tests passed.
  • Gradle plugin tests passed.
  • apiCheck, Detekt, Android lint, module-structure checks, generated test runners, and ktfmt passed.
  • Fresh cross-module Wasm and iOS simulator compilations passed with Metro IR generation enabled.
  • Configuration-cache storage and reuse passed.
  • Production Wasm distributions for both sample and recipes passed.

Upstream references: Kotlin 2.4.20-Beta2, Kotlin EAP configuration, Metro compiler API, Metro issue #2576, and Metro PR #2590.

@vRallev
vRallev force-pushed the ralf/kotlin-2.4.20-beta2 branch 3 times, most recently from ecc7c7b to 65d913b Compare July 31, 2026 20:51
vRallev added 3 commits August 6, 2026 21:17
Move the main build from Kotlin 2.4.10 to 2.4.20-Beta2 and adapt the compiler extension APIs and test goldens for the new compiler.

Metro's IR mode no longer invokes App Platform's FIR declaration generators, while downstream Native and Wasm compilations still need FIR package hints to discover contributions. Generate renderer, robot, and scoped binding containers in IR through Metro's contribution API, retain FIR only for cross-module hints, and order App Platform's compiler plugin before Metro's graph transformation. This keeps Metro class generation in IR enabled on every target.

Update the affected generated API snapshots and leave the standalone blueprints unchanged.
Move renderer, robot, and scoped target resolution off FIR metadata when Metro's IR class generation is enabled. This keeps JVM consumers on a pure IR path while retaining FIR contribution hints only for cross-module discovery in KLIB targets.

Mirror Metro's generation option into the App Platform compiler plugin so the FIR fallback remains mode-correct, and run the box corpus without FIR hints to cover the IR-only behavior.
Metro 1.4.1 generates FIR contribution hints alongside IR class generation on Kotlin 2.4.20+, including Native and Wasm. Restore App Platform's FIR declaration shells and existing IR body fillers, remove the custom option rewriting and all-IR generation path, and make compiler tests exercise Metro's production FIR/IR configuration.
@vRallev
vRallev force-pushed the ralf/kotlin-2.4.20-beta2 branch from 65d913b to 611c850 Compare August 7, 2026 04:38
vRallev added 2 commits August 6, 2026 21:48
Kotlin 2.4.20 deprecates `IrAnnotation.symbol`, and fresh CI builds reject the warning under `-Werror`. Read `classSymbol` directly so the compiler plugin remains compatible with the supported IR API.
Metro 1.4.2 was released on 2026-08-14 and fixes typealias resolution in `KClass` annotation arguments, `@Origin`-chain exclusions and replacements, Kotlin/JS provider-field collisions for inherited member injection, Dagger-interop crashes for deeply nested class names, and incremental regeneration when `GraphExtension` members change. These fixes reduce compiler-plugin risk for App Platform’s generated contributions and graph extensions; current call sites require no compatibility changes. Metro also tests Kotlin 2.4.20-RC, which covers the project’s 2.4.20-Beta2 compiler line.

Upgrade `dev.zacsweers.metro:compiler`, `dev.zacsweers.metro:gradle-plugin`, and `dev.zacsweers.metro:runtime` from 1.4.1 to 1.4.2 through `gradle/libs.versions.toml`, and update `CHANGELOG.md`. The compiler remains on Java 21, the runtime still declares Kotlin stdlib 2.3.0, and the Gradle plugin keeps kotlinx-serialization JSON 1.11.0, so platform and transitive dependency floors are unchanged. The standalone `blueprints/` projects remain untouched.

No publicly discoverable 1.4.2-specific issue was found in Metro’s GitHub tracker, security advisories, or Google Issue Tracker as of 2026-08-14 UTC. Confidence is limited because this is a same-day release. The repository’s Metro version history is monotonic and contains no prior Metro rollback.

Release: https://github.com/ZacSweers/metro/releases/tag/1.4.2
Comparison: ZacSweers/metro@1.4.1...1.4.2
GitHub issues: https://github.com/ZacSweers/metro/issues?q=is%3Aissue+%221.4.2%22
Google Issue Tracker: https://issuetracker.google.com/issues?q=%22dev.zacsweers.metro%22%20%221.4.2%22
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