Kotlin Help

Compatibility guide for Kotlin 1.9

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 1.8 to Kotlin 1.9.

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

Remove language version 1.3

Prohibit super constructor call when the super interface type is a function literal

Prohibit cycles in annotation parameter types

Prohibit use of @ExtensionFunctionType annotation on function types with no parameters

Prohibit Java field type mismatch on assignment

No source code excerpts in platform-type nullability assertion exceptions

Prohibit the delegation of super calls to an abstract superclass member

Deprecate confusing grammar in when-with-subject

Prevent implicit coercions between different numeric types

Prohibit upper bound violation in a generic type alias usage (a type parameter used in a generic type argument of a type argument of the aliased type)

Keep nullability when approximating local types in public signatures

Do not propagate deprecation through overrides

Prohibit using collection literals in annotation classes anywhere except their parameters declaration

Prohibit forward referencing of parameters in default value expressions

Prohibit extension calls on inline functional parameters

Prohibit calls to infix functions named suspend with an anonymous function argument

Prohibit using captured type parameters in inner classes against their variance

Prohibit recursive call of a function without explicit return type in compound assignment operators

Prohibit unsound calls with expected @NotNull T and given Kotlin generic parameter with nullable bound

Prohibit access to members of a companion of an enum class from entry initializers of this enum

Deprecate and remove Enum.declaringClass synthetic property

Deprecate enable and compatibility modes of the compiler option -Xjvm-default

Prohibit implicit inferring a type variable into an upper bound in the builder inference context

Standard library

Warn about potential overload resolution change when Range/Progression starts implementing Collection

Migrate declarations from kotlin.dom and kotlin.browser packages to kotlinx.*

Deprecate some JS-only API

Tools

Remove enableEndorsedLibs flag from Gradle setup

Remove Gradle conventions

Remove classpath property of KotlinCompile task

Deprecate kotlin.internal.single.build.metrics.file property

Last modified: 25 September 2024