Kotlin 1.2.50 is out!

Posted on by

We’re happy to announce the release of Kotlin 1.2.50, a new bugfix and tooling update for Kotlin 1.2. This release:

Updates Kotlin support in the Eclipse IDE plugin

Adds new functions in common and JS parts of the standard library

Brings JUnit 5 support to kotlin.test

Improves experimental scripting support

Introduces Runnable Kotlin scratch files in IntelliJ IDEA

Speeds up building multimodule Android projects with Gradle

Updates experimental @JvmDefault support with a binary compatibility mode

support with a binary compatibility mode Introduces a progressive compiler mode

Fixes a lot of known issues in the compiler and the IDE plugin and provides performance improvements

The update is compatible with all versions of IntelliJ IDEA from 2017.2 to 2018.2 EAP, as well as with Android Studio 3.0, 3.1, and 3.2 Canary.

We’d like to thank our external contributors whose pull requests were included in this release: Toshiaki Kameyama, Mikaël Peltier, Raluca Sauciuc, meztihn, Ivan Gavrilovic, Denis Vnukov, Derek, Florian Steitz, Jim S, Evgeny Zakharov, Aaron Nwabuoku, Alexey Belkov, Claus Holst, Elifarley C, Felix Guo, Gabryel Monteiro, Gilkeson, Juan Chen, Mon_chi, Valeriy Zhirnov, Steven Spungin, Swapnil Sankla, TakuyaKodama, and Kenji Tomita

The complete list of changes in this release can be found in the changelog. Read on for the highlights.

Eclipse IDE plugin update

We are proud to present the new 0.8.5 release of our plugin for the Eclipse IDE. Along with support for the Kotlin 1.2.50 compiler, this update brings several features and improvements such as:

support for the Kotlin compiler plugins like kotlin-allopen and kotlin-spring

and preferences in configuring the version of the generated JVM bytecode

bug-fixes in the debugger and J2K converter

Workspace-wide Kotlin compiler preferences, which allow you to configure compiler plugins and other compiler options, can be found in Preferences | Kotlin | Compiler. It is also possible to configure only project-level settings.

The updated Kotlin Eclipse Plugin is available on the Eclipse Marketplace. See the ‘Getting Started’ tutorial for details.

Library updates

In this update, a set of toString(radix: Int) extension functions for Byte , Short , Int , and Long were added to the common and Kotlin/JS parts of the standard library, thanks to our contributor Florian Steitz. They are ready for use in experimental multiplatform projects and projects targeting JavaScript.

Another addition to the common and Kotlin/JS standard library parts are the two constructors, String(chars: CharArray) and String ( : , : , : Int) . These are meant for efficient conversion of a CharArray to String . This change was contributed by Valeriy Zhirnov.

Also, the kotlin.test library now supports testing with the JUnit 5 framework with a separate module kotlin-test-junit5 , which provides an implementation of Asserter on top of JUnit 5 and maps the test annotations from kotlin-test-annotations-common to the JUnit 5 test annotations.

Improved experimental scripting support

This release introduced new experimental scripting support that allows easier kotlin scripts customization, simpler use of the scripts with standard compiler and IDEA plugin, and simpler scripting host creation and embedding. The complete Kotlin scripting proposal along with the current implementation state could be found in the appropriate KEEP. Some highlights include:

it is now possible to create a jar defining a script and if that jar is added to the compilation classpath, the scripts of this type will be automatically supported by the compiler and IDEA plugin

it is now possible to pass typed external variables to the script compilation, so they will be accessible as if they are global variables defined outside of the script

the structure of the scripting support is now much simpler and provided helpers allow to implement and embed a custom scripting host much easier than before

IntelliJ IDEA plugin improvements

Runnable Kotlin scratch files and Kotlin scripts

The update of the Kotlin IntelliJ IDEA plugin introduces support for runnable Kotlin scratch files. These can use the declarations from the code in the project as well:

Besides, IDE support for Kotlin Script ( *.kts ) files has been improved. You can now create new scripts in the Project View and run them within the classpath of the module they are placed in.

Raw strings input and indentation

The updated IDE plugin makes it easier to type raw string literals, as it now inserts the pairing """ automatically and provides an intention to indent the literal (thanks to our contributor Toshiaki Kameyama). This is useful when you paste a multiline string:

Other improvements in the IntelliJ IDEA plugin

A few new inspections and intentions that are here to help with kotlinx.coroutines – these detect unused Deferred and async results and convert async(ctx) { }.await() to withContext(ctx) { } .

– these detect unused and results and convert to . An intention to convert end-of-line comments into block ones and vice versa.

A lot of bugfixes, stability improvements and performance optimizations.

Faster Gradle builds

Starting with Kotlin 1.2.50, Kotlin tracks changes incrementally across the modules of a multimodule Android project. This results in significantly faster incremental builds of large Android projects with multiple interdependent modules.

Changes in the compiler

The Kotlin 1.2.50 update fixes a lot of known issues in the compiler, delivers performance and stability improvements, and adds the new features listed below.

Progressive compiler mode

While most bugs and inconsistencies found in the Kotlin compiler are fixed as soon as possible, some of the fixes may potentially be backward-incompatible. The Kotlin compatibility policy requires us to introduce such fixes only in major releases (such as 1.1 and 1.2) and go through lengthy migration cycles. We, however, believe that many users will benefit from these bug-fixes being delivered quicker, making their code safer and cleaner.

In this release, we introduce an experimental progressive compiler mode intended for actively developed codebases whose maintainers regularly update to latest versions of the Kotlin compiler and tools. In this mode, some of the deprecations and bug-fixes for unstable code take effect immediately. Consequently, some code may break upon enabling the mode or upon updating Kotlin to future versions while keeping the progressive mode enabled.

Fixes that are chosen to be enabled in the progressive mode won’t affect too many places in the codebases, though they won’t work silently and will require the maintainers to fix the erroneous pieces of code. We are going to provide automated migration tools in the IDE plugin for this where possible. Any code fixed in this way will stay valid outside the progressive mode, too. For examples of issues with fixes applied in the progressive mode, see KT-9580, KT-16681, or KT-17981.

You can enable the progressive mode on a per-module basis by adding the flag -Xprogressive to the arguments passed to the Kotlin compiler.

@JvmDefault binary compatibility mode

Experimental support for generating default methods for JVM interfaces with @JvmDefault has been updated to compile the default methods in a way that is binary-compatible with normal default implementations in Kotlin interfaces. To switch to this mode, use the compiler flag -Xjvm-default=compatibility .

Also note that the compiler flag -Xenable-jvm-default introduced in Kotlin 1.2.40 is no longer supported. Please use -Xjvm-default=enable instead.

Argument files

Kotlin 1.2.50 supports passing compiler arguments in a file with the command line option -Xargfile=args.txt , which helps call the command line compiler with long filesystem paths in the arguments.

How to update

To update your IntelliJ IDEA or Android Studio plugin, use Tools | Kotlin | Configure Kotlin Plugin Updates and click the ‘Check for updates now’ button. The Eclipse IDE plugin can be installed or updated via the Eclipse Marketplace (Help | Eclipse Marketplace and search for the Kotlin plugin).

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!