Kotlin Help

Compatibility guide for Kotlin 2.4.x

Keeping the Language Modern and Comfortable Updates are among the fundamental principles in Kotlin Language Design. The former says that constructs which obstruct language evolution should be removed, and the latter says that this removal should be well-communicated beforehand to make code migration as smooth as possible.

While most of the language changes were already announced through other channels, like update changelogs or compiler warnings, this document summarizes them all, providing a complete reference for migration from Kotlin 2.3 to Kotlin 2.4. This document also includes information about tool-related changes.

Basic terms

In this document, we introduce several kinds of compatibility:

  • source: source-incompatible change stops code that used to compile fine (without errors or warnings) from compiling anymore

  • binary: two binary artifacts are said to be binary-compatible if interchanging them doesn't lead to loading or linkage errors

  • behavioral: a change is said to be behavioral-incompatible if the same program demonstrates different behavior before and after applying the change

Remember that those definitions are given only for pure Kotlin. Compatibility of Kotlin code from the other languages perspective (for example, from Java) is out of the scope of this document.

Language

Drop support for -language-version=1.9 and the K1 compiler

Prohibit flexible explicit nullable type arguments for Java types

Prohibit always-false is checks for definitely incompatible types

Prohibit exposing types and declarations with lower visibility in inline functions

Change default use-site target selection for annotations

Forbid implicit references to inaccessible types

Enforce Jakarta nullability annotations

Report misplaced type arguments in callable reference qualifiers

Report errors for class literals from reified type parameters with nullable upper bounds

Prohibit initialization before declarations in anonymous objects

Enforce exhaustiveness for when expressions with non-abstract Java sealed classes

Prohibit operator modifier on getValue() and setValue() functions with too many parameters

Prohibit inconsistent type arguments in generic calls

Deprecate references to the javaClass property

Report errors for implicit enum constructor calls that require opt-in

Forbid inline modifier on enum entries

Prohibit array literals outside annotation calls and parameter defaults

Prohibit _root_ide_package_ in CLI compiler mode

Correct equality for function references with vararg conversions

Enforce opt-in for companion object access

Report type mismatches from supertypes with nested generic arguments

Prohibit inferred types with inaccessible declarations

Standard library

Deprecate kotlin.io.readLine() function

Change Random.nextDouble() contract for infinite bounds

Tools

Deprecate legacy Kotlin/JS compiler type selection APIs

Deprecate sourceSets in the Kotlin Android extension

Remove consumable configurations for Kotlin/Native Apple frameworks

Remove deprecated task, compilation, and DSL APIs from the Kotlin Gradle plugin

Deprecate explicit shrunk classpath snapshot configuration

Remove redundant ABI validation Gradle DSL elements

Deprecate obsolete Compose compiler Gradle plugin options

Report errors for obsolete Kotlin/Native Gradle task APIs

02 June 2026