We’re happy to announce the release of Kotlin 1.2.30, a new bugfix and tooling update for Kotlin 1.2. This update:
- Adds a new declaration in the standard library, which imitates the
suspendmodifier for lambda expressions
- Adds support for TestNG in
- Brings support for Android modules in multiplatform projects
- Introduces a new feature in kapt for reporting annotation processing errors along with proper links to the original Kotlin declarations
- Adds a lot of new inspections and intentions in the IntelliJ plugin and improves its performance
- Fixes bugs in the compiler and IntelliJ plugin
The update is compatible with all versions of IntelliJ IDEA from 2017.1 until 2017.3 and 2018.1 EAP, as well as with Android Studio 3.0 and Android Studio 3.1 (Beta)
We’d like to thank our external contributors whose pull requests were included in this release: Toshiaki Kameyama, Kenji Tomita, Yoshinori Isogai, Kirill Rakhman, Vsevolod Tolstopyatov, Adam McNeilly, Chris Povirk, Cuihtlauac Alvarado, Emmanuel Duchastenier, Jake Wharton, Joscha Alisch, Rodrigo B. de Oliveira, Valeriy Zhirnov.
The complete list of changes in this release can be found in the changelog.
Changes in the libraries
This release adds a new function to the Kotlin standard library with the following signature:
The purpose of this function is to wrap a function literal into a value of a suspending function type and enable its usage as a suspending function. Example:
It’s important to note that adding this function is a preliminary step in gradually introducing a
suspend modifier for lambda expressions in the future Kotlin versions. Usages of the function that would not be valid if it was a modifier, such as taking a function reference to it or using a labeled
return@suspend, are prohibited, and the calls to third-party
suspend-named functions that would clash with the modifier are now deprecated.
Another notable change is the support for the TestNG framework in
kotlin.test – thanks to our contributor Valeriy Zhirnov! The new artifact
kotlin-test-testng provides an implementation of
Asserter on top of TestNG and maps the test annotations from
kotlin-test-annotations-common to the TestNG test annotations.
Platform modules targeting Android
The update of the experimental multiplatform projects feature introduces support for Android platform modules. These modules should apply the corresponding plugin in the Gradle build script and can use the shared code from a common module:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-platform-android'
A simple project layout example can be found in the Kotlin repository:
Kapt diagnostic locations
With Kotlin 1.2.30, kapt, the Kotlin annotation processing tool, can provide links to locations in the original Kotlin code rather than generated Java stubs as it reports errors encountered during annotation processing. This feature can be enabled by adding these lines to the Gradle build script (
mapDiagnosticLocations = true
This will include the original locations in the Kotlin files into error reports from the annotation processors, for example:
e: src/main/kotlin/Foo.kt:47: error: @Provides methods must not be private
Deprecation of old kapt
Original kapt was deprecated a year ago, and in 1.2.30 we changed the deprecation warning to an error. The migration process to the new kapt (aka kapt3) is very easy, just apply a
kotlin-kapt plugin in your
apply plugin: "kotlin-kapt"
If you experience any troubles with the new kapt, please let us know.
IntelliJ IDEA plugin improvements
This release brings various improvements in the IntelliJ IDEA Kotlin plugin, such as performance improvements, bug fixes, and new inspections and intentions.
Intentions for converting the scoping function calls
Kotlin 1.2.30 adds new intentions that convert calls to the scoping functions
run and into each other, as well as
apply and vice versa:
Pasting Kotlin code into a package
The IntelliJ plugin now allows pasting Kotlin code into a package item in the Project View, creating a new Kotlin file for the code:
Other changes in the IDE plugin
- Data flow analysis (‘Analyze Data Flow …’) support for mixed Kotlin and Java codebases
- An option to create a run configuration for a Node CLI application from a
mainfunction in Kotlin/JS projects
- Improvements in the Rename/Move refactoring, such as warnings on possible conflicts introduced by renaming
Changes in the compiler
The Kotlin 1.2.30 update fixes several known issues in the Kotlin compiler and includes performance improvements.
The compiler is now able to optimize a tail call made in a suspending function to another
Unit-returning suspending function, resulting into more efficient compiled code.
How to update
To update the plugin, use Tools | Kotlin | Configure Kotlin Plugin Updates and press the “Check for updates now” button. Also, don’t forget to update the compiler and standard library version in your Maven and Gradle build scripts.
As usual, if you run into any problems with the new release, you’re welcome to ask for help on the forums, on Slack (get an invite here), or to report issues in the issue tracker.