Kotlin 2.4.20 Ships With Sealed-Class Swift Export, New Wasm Compilation Modes and an Experimental Native Compiler Image
Kotlin 2.4.20, released September 7, maps sealed classes to Swift enums, adds new Kotlin/Wasm compilation modes, and ships a first experimental native compiler image.
Editor's Note ·
- Correction:
- The article states that JetBrains' blog post 'summarizes the release in six bullet points spanning the standard library, Kotlin/Native, Kotlin/Wasm, Kotlin/JS, Gradle and the Build Tools API.' The JetBrains blog post (blog.jetbrains.com/kotlin/2026/09/kotlin-2-4-20-released/) actually lists seven bullet categories: Standard library, Kotlin/Native, Kotlin/Wasm, Kotlin/JS, Gradle, Build tools API, and Kotlin compiler. The article's enumeration omitted the 'Kotlin compiler' bullet (covering the kotlinr runner rename and the experimental native compiler image).
Overview
JetBrains released Kotlin 2.4.20 on September 7, a minor update that touches the standard library, Kotlin/Native, Kotlin/Wasm, Kotlin/JS, Gradle tooling, the Build Tools API and the compiler itself. According to the official “What’s new in Kotlin 2.4.20” page, the release’s headline changes include new Swift export capabilities for sealed classes, additional Kotlin/Wasm compilation modes, and the first experimental build of a native Kotlin compiler image. JetBrains’ announcement frames it simply: “The Kotlin 2.4.20 release is out! Here are the main highlights:“
What We Know
Swift export gains sealed classes and cross-language inheritance
Kotlin’s release notes say “Kotlin 2.4.20 adds support for sealed classes and interfaces to Swift export.” Previously, developers exporting a sealed hierarchy to Swift had to write a default case for every switch statement over the type; now, according to the notes, “sealed hierarchies defined in Kotlin are mapped to Swift enums, enabling exhaustive switch statements with full autocompletion in Xcode.” The release also introduces cross-language inheritance support in Swift export, which the notes describe as useful for the “reverse import” pattern, where a contract is defined in Kotlin and implemented on the Swift side — a pattern the notes say is “especially useful when you need to use pure Swift libraries that can’t be directly imported into Kotlin.” Separately, the assembleSharedXCFramework Gradle task now generates a Package.swift file alongside exported XCFrameworks that depend on Swift Package Manager dependencies, per the release notes.
Kotlin/Wasm adds compilation modes and shrinks binaries
Kotlin/Wasm gets three selectable compilation modes in 2.4.20, according to the release notes: the default monolith mode, which compiles a project and its dependencies together into a single optimized binary; multimodule-open-world, which compiles each module independently into its own binary without cross-module optimization; and multimodule-closed-world, which processes all modules in one invocation and produces separate, interdependent binaries. The release also changes how the compiler handles lambdas and functional interfaces on Kotlin/Wasm, generating functions with shared base classes instead of separate anonymous classes. The notes say tests with the KotlinConf application show this “reduces Wasm binary size by approximately 5–10%,” while cautioning that “because the change introduces more dynamic calls, it may affect runtime performance.” The Kotlin Gradle plugin also adds support for running the wasmWasi target on Wasmtime as a standalone runtime, where previously it supported only Node.js as a JavaScript bootstrap, according to the release notes.
Standard library, Kotlin/JS and compiler changes
The standard library adds a StackTraceRecoverable interface intended to help the kotlinx.coroutines library recover stack traces “when one coroutine throws an exception and another rethrows it,” per the release notes, along with four new experimental collection functions — allDistinct(), allDistinctBy(), allEqual() and allEqualBy() — for checking equality and uniqueness across collections, sequences and arrays. kotlin.test assertion functions such as assertTrue() and assertEquals() gain overloads that accept a lazily evaluated error-message lambda instead of a pre-built string, which the notes say “align the kotlin.test API with JUnit 5” and improve performance for the Power-assert compiler plugin. On Kotlin/JS, the release adds a new experimental DSL for browser testing built on Playwright and Mocha, intended to replace the Karma test runner, which the release notes describe as having “been deprecated for two years now.” Kotlin/JS also gains support for exporting suspending lambda expressions as JavaScript async functions. On the tooling side, the Build Tools API extends beyond Kotlin/JVM to Kotlin/JS, Kotlin/Wasm and Kotlin metadata as an opt-in feature, according to the release notes, which add that JetBrains plans to enable it by default “starting with Kotlin 2.5.0.” The compiler’s command-line runner is renamed from kotlin to kotlinr to avoid a naming conflict with the separate Kotlin Toolchain project, and the release ships the first experimental build of a native Kotlin compiler image, described in the release notes as “a drop-in replacement for the standard kotlinc command-line tool, while offering faster startup time and higher performance.”
JetBrains’ own summary matches the detailed notes
JetBrains’ blog post summarizes the release in six bullet points spanning the standard library, Kotlin/Native, Kotlin/Wasm, Kotlin/JS, Gradle and the Build Tools API, matching the detailed breakdown on the documentation site section for section — including, on Gradle, “support for Gradle 9.7.0 and improved reporting in the Problems API,” where the compiler now attaches diagnostic IDs to information passed through Gradle’s Problems API, according to the release notes.
What We Don’t Know
The release notes do not specify an exact release day and time beyond the “Released: September 7, 2026” line on the documentation page, nor do they disclose adoption figures, benchmark methodology behind the 5–10% Kotlin/Wasm binary-size figure beyond referencing the KotlinConf application, or a firm timeline for stabilizing any of the release’s experimental and beta-tagged features — the incremental compilation of klib artifacts, for instance, is described only as newly moved to Beta after originating in Kotlin 1.9.20.