Kotlin 1.0.5 is here
Dmitry JemerovWe’re happy to announce that we’ve just released Kotlin 1.0.5, which continues the series of bugfix and tooling updates for Kotlin 1.0.
We’d like to thank our external contributors whose pull requests were included in this release: Kirill Rakhman, Vladislav Golub, Vsevolod Tolstopyatov, Yoshinori Isogai, takahirom and gitreelike. Thanks to everyone who tried the EAP builds and sent us feedback, too!
The complete list of changes in the release can be found in the changelog. Some of the changes worth highlighting are:
Loop to Lambda Conversion
The IntelliJ IDEA plugin can now detect many cases where imperative for
loops can be rewritten in a more compact and idiomatic manner using standard library functions such as filter
and map
. As a simple example, the following snippet:
val result = arrayListOf<String>()
for (s in list) {
if (s.isNotEmpty()) {
result.add(s)
}
}
...will be automatically converted to:
val result = list.filter { it.isNotEmpty() }
To trigger the conversion, put the caret on the for
keyword and press Alt-Enter.
Postfix Code Completion
IntelliJ IDEA’s postfix code completion is now supported for Kotlin, with a large array of templates. Note that the feature depends on platform changes made in IntelliJ IDEA 2016.2 and is therefore unavailable in Android Studio 2.2; it will be supported in newer versions of Android Studio based on newer IntelliJ Platform versions.
New Refactorings
The Kotlin plugin now supports “Extract Interface” and “Extract Superclass” refactorings, which were previously only supported only for Java and some other languages, as well as an entirely new refactoring “Introduce Type Parameter”, providing an easy way to change a class or function into a generic one.
Android IDE Support Improvements
Kotlin 1.0.5 updates the Kotlin Lint checks to feature parity with Android Studio 2.2’s Java Lint checks, fixing a lot of issues in the process. It also adds a long-awaited feature: “Extract string resource” intention, allowing to move a hard-coded string literal from Kotlin code to a string resource file.
JavaScript Support Improvements
Kotlin 1.0.5 adds two major new features to the JavaScript backend:
- The
@JsName
annotation allows to control the names of JavaScript functions and properties generated from Kotlin code, making it much easier to call Kotlin-compiled code from plain JavaScript; - Class literals (
Foo::class
) are now supported. The value of a::class
expression does not implement the fullKClass
API; it only defines asimpleName
property to access the class name.
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.
Let’s Kotlin!