Guard conditions, introduced in Kotlin 2.1.0 last November, are now stable. Guard conditions allow for including more than one condition for the branches of a when
expression, making complex control flows more explicit and concise, JetBrains said. Additionally, code structure is flattened with this feature.
A new compiler option in Kotlin 2.2.0, -XWarning-level
, is designed to offer a unified way of managing compiler warnings in Kotlin projects. Previously, developers only could apply general module-wide rules, such as disabling all warnings with nowarn
or turning warnings to compilation errors with -Werror
. With the new option, developers can override general rules and exclude specific diagnostics in a consistent way.
Other new features and improvements in Kotlin 2.2.0: