Kotlin 1.4.31 Help

Compatibility guide for Kotlin 1.3

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.2 to Kotlin 1.3.

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 one and 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 (e.g. from Java) is out of the scope of this document.

Incompatible changes

Evaluation order of constructor arguments regarding call

Missing getter-targeted annotations on annotation constructor parameters

Missing errors in class constructor’s @get: annotations

Nullability assertions on access to Java types annotated with @NotNull

Unsound smartcasts on enum members

val backing field reassignment in getter

Array capturing before the for-loop where it is iterated

Nested classifiers in enum entries

Data class overriding copy

Inner classes inheriting Throwable that capture generic parameters from the outer class

Visibility rules regarding complex class hierarchies with companion objects

Non-constant vararg annotation parameters

Local annotation classes

Smartcasts on local delegated properties

mod operator convention

Passing single element to vararg in named form

Retention of annotations with target EXPRESSION

Annotations with target PARAMETER shouldn't be applicable to parameter's type

Array.copyOfRange throws an exception when indices are out of bounds instead of enlarging the returned array

Progressions of ints and longs with a step of Int.MIN_VALUE and Long.MIN_VALUE are outlawed and won’t be allowed to be instantiated

Check for index overflow in operations on very long sequences

Unify split by an empty match regex result across the platforms

Discontinued deprecated artifacts in the compiler distribution

Annotations in stdlib

Last modified: 04 March 2021