Kotlin Help

Compatibility guide for Kotlin 2.2

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.1 to Kotlin 2.2.

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

Enable invokedynamic for annotated lambdas by default

Prohibit constructor call and inheritance on type aliases with variance in expanded types in K2

Prohibit synthetic properties from Kotlin getters

Change default method generation for interface functions on JVM

Forbid field-targeted annotations on annotation properties

Forbid reified type parameters in type aliases

Correct type checks on inline value classes for Number and Comparable

Prohibit inaccessible generic types from indirect dependencies

Enforce visibility checks on type parameter bounds

Report errors when exposing private types in non-private inline functions

Forbid non-local returns in default argument lambdas

Standard library

Deprecate kotlin.native.Throws

Deprecate AbstractDoubleTimeSource

Tools

Correct setSource() function in KotlinCompileTool to replace sources

Deprecate KotlinCompilationOutput#resourcesDirProvider property

Deprecate BaseKapt.annotationProcessorOptionProviders property

Deprecate kotlin-android-extensions plugin

Deprecate kotlinOptions DSL

Remove kotlin.incremental.useClasspathSnapshot property

Deprecations to Kotlin scripting

Deprecate disambiguation classifier properties

Deprecate commonization parameters

Deprecate support for legacy metadata compilation

Deprecate KotlinCompilation.source API

Deprecate target presets APIs

Deprecate Apple target shortcuts

Deprecate publishAllLibraryVariants() function

Deprecate android target

Deprecate konanVersion in CInteropProcess

Deprecate destinationDir in CInteropProcess

Deprecate kotlinArtifacts API

02 July 2025