Kotlin 1.2.20 is out
We’re happy to announce the release of Kotlin 1.2.20, a new bugfix and tooling update for Kotlin 1.2. This update:
- Adds support for Gradle build cache
- Improves incremental compilation for Android and mixed Kotlin/Java projects
- Provides IDE support for the new Kotlin style guide
- Adds inlay hints in the editor for implicit parameters and receivers of lambdas, as well as values returned from lambdas
- Introduces new inspections, performance improvements and bug fixes in the IntelliJ plugin
The update is compatible with all versions of IntelliJ IDEA from 2017.1 until 2017.3, as well as with Android Studio 3.0 and 3.1 Canary.
The complete list of changes in this release can be found in the changelog.
We’d like to thank our external contributors whose pull requests were included in this release: Toshiaki Kameyama (with an impressive number of contributions – 46 commits!), Yoshinori Isogai, Kenji Tomita, Kirill Rakhman, Sergey Ryabov, Alexey Belkov, Michal Bendowski, AdamMc331, Andre Perkins, Andrey Mischenko, Artem Zinnatullin, Chris Povirk, Denis Vnukov, Dereck Bridie, Ilya Zorin, Jake Wharton, Joscha Alisch, Kartik Patodi, AJ Alt, Ramon Wirsch, Vladimir Kasatkin, Yusuke Hosonuma, a2kaido, scache.
Compilation Performance Improvements
Compilation performance continues to be a major focus for us, and in this release we’ve mostly delivered improvements related to the Gradle plugin.
The first improvement is the support for Gradle build cache. If you’re using Gradle 4.3 or newer and the build cache is enabled (it’s not by default, requires
org.gradle.caching=true), the plugin will reuse compilation results from previous executions of the Kotlin compile task. For example, if you build the
master branch of your code, then switch to a different branch, build again, and switch back to
master, the code will not be recompiled – previous results of
master compilation will be reused.
Build caching for Kotlin annotation processors is disabled by default, because the dependencies of annotation processors cannot be tracked precisely by Gradle, so it may incorrectly reuse results of a previous execution of an annotation processors. To enable caching anyway, add the following lines to the build script:
The second improvement is more precise tracking of changes in Java files, allowing to avoid Kotlin recompilation when the changes in Java do not affect Kotlin code. This feature is experimental; to enable it, add the following line to your gradle.properties file:
Finally, changes to Android layout XML files no longer cause recompilation of all Kotlin sources; only Kotlin files that reference properties generated by Kotlin Android Extensions (
kotlinx.android.synthetic.*) are recompiled.
Kotlin Style Guide
We’ve recently released a new official Kotlin style guide, covering the formatting of Kotlin code and the idiomatic use of language and library features. Since this version, the formatter fully supports the new style guide. Also, many style guide violations can be detected with IntelliJ IDEA inspections and corrected with quick fixes.
The formatting suggested by the new style guide is different in several aspects from the default formatting previously used by the Kotlin plugin. In order to avoid unwanted formatting changes, you need to apply the new style guide explicitly. In order to do that, go to Settings | Editor | Code Style | Kotlin and use the “Set from…” link to choose the code style.
IntelliJ IDEA Plugin Improvements
The new version of the plugin adds inlay editor hints for implicit parameters of lambdas, as well as for values returned from lambdas. The following screenshot illustrates both features in action.
runDceKotlinJs.dceOptions.devMode = true
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.