Kotlin 2.4.0, an update to JetBrains’s statically typed language for building JVM, native, Wasm, and web applications, introduces experimental improvements to compile-time constants, making support for numeric and string types more consistent and easier to use, JetBrains said.
Kotlin 2.4.0 was released June 3. Its experimental improvements to compile-time constants include support for unsigned type operations; standard library functions for strings, such as the .lowercase(), .uppercase(), and .trim() functions, and evaluation of the .name property of enum constants and the KCallable interface. To make it clear which functions are evaluated at compile time, Kotlin 2.4.0 introduces the IntrinsicConstEvaluation annotation.
JetBrains warned that some functions are evaluated at compile time but do not have the annotation yet. Later releases will add the annotation to the remaining functions.
Also in Kotlin 2.4.0:
- Kotlin 2.4.0 improves export to JavaScript and TypeScript, including support for exporting value classes, interfaces, and type variance, as well as ES2015 features when inlining JavaScript code.
- The Kotlin compiler can generate classes containing Java 26 bytecode.
- Experimental support is highlighted for the WebAssembly Component Model. The proposal defines a way to build components from Wasm modules through standardized interfaces and types. This approach helps Wasm evolve from a low-level binary instruction format into a system for composing reusable, language-agnostic components.
- Kotlin 2.4.0 has been included in the IntelliJ IDEA and Android Studio IDEs.
An update to Kotlin 2.4.0 will arrive soon. Beta1 of Kotlin 2.4.20 was released on June 24, adding the StackTraceRecoverable interface to the standard library. This interface improves integration with the kotlinx.coroutines library because it lets users define how to create exception instances for stack trace recovery without adding a dependency onkotlinx.coroutines, according to JetBrains.
A build tools API in the Kotlin 2.4.20 beta adds support for the Kotlin/JS, Kotlin/Wasm, and Kotlin metadata targets.