Kotlin 1.2.30 is out

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 suspend modifier for lambda expressions
  • Adds support for TestNG in kotlin.test
  • 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:

A simple project layout example can be found in the Kotlin repository: multiplatformAndroidProject

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 (build.gradle):

This will include the original locations in the Kotlin files into error reports from the annotation processors, for example:

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 build.gradle file:

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 let and run and into each other, as well as also into 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 main function 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.

Let’s Kotlin!

This entry was posted in Releases and tagged . Bookmark the permalink.

17 Responses to Kotlin 1.2.30 is out

  1. You are fast. Thank you for good news

  2. You probably want to update changelog link to this one (or with fixed commit) https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md#1230 :)

    Currently it points to 1.2.30 branch where Changelog title has “Work In Progress”

  3. Christian says:

    I wonder why there is a special way to update the Kotlin plug-in. If I check for updates with Help > Check for Updates … the new Kotlin plug-in is not found.

    • jtonic says:

      Hi Christian,

      I think the reason behind this is the fact there are channels to updates new version from – EAP, stable. I don’t think there is such support in Check for Updates…
      If I remember well I think scala plugin has a similar way of being update.

    • Cristan Meijer says:

      You can use Tools>Kotlin>Configure Kotlin Plugin Updates>Check for updates now

  4. Louis CAD says:

    Plugin still not available on Android Studio Canary 3.1 & 3.2 (beta4 and alpha4 respectively). Using mixed EAP plugin stable gradle plugin + stdlib for 1.2.30 at the moment.

  5. kirillkh says:

    Hi,

    After updating to 1.2.30 from 1.2.21, I started getting error “Could not connect to Kotlin compile daemon” when trying to execute :compileKotlin Gradle task. Invalidate caches/restart didn’t help. Reverting back to 1.2.21 in build.gradle does help, even though the installed plugin is still 1.2.30.

    :kaptGenerateStubsKotlin
    Could not perform incremental compilation: Could not connect to Kotlin compile daemon
    Could not connect to kotlin daemon. Using fallback strategy.

    • kirillkh says:

      Further inspection shows the project now has two kotlin libs versions: 1.2.30 and 1.2.20 as follows: https://i.imgur.com/ZK2lsSE.png

    • kirillkh says:

      Well, it turns out I had mini-dependency hell… The following two packages require their own Kotlin versions: kotlinx-coroutines-jdk8:0.22.3 (requires 1.2.21), vertx-lang-kotlin:3.5.1 (requires 1.2.20). For the lack of a better choice, I rolled everything back far enough that it all requires 1.2.20.

    • Have you tried some dependencyManagement configuration?

  6. Christoph Pickl says:

    looking great, and i love the new inspections. although… the “remove redundant backticks” reports some false positives. so now all the test methods are marked yellow, although the names contain whitespace, so no way to remove the backticks 😉

  7. Thomas Wooldridge says:

    Awesome!

    FYI: 1.2.30 isn’t available in the stable channel for Android Studio 3.2 Canary x. No biggee – I downloaded it from https://plugins.jetbrains.com/plugin/6954-kotlin && updated the plugin from disk.

  8. Chris Rankin says:

    Hi,
    I notice that the internal ProtoBuf API in the kotlin.reflect.jvm.internal.impl.serialization.* packages has gained some “writeTo()” methods which were present in the source files for 1.2.2x but suspiciously absent from the class files. I can definitely use these “writeTo()” methods because I have some @kotlin.Metadata annotations that I need to modify having used ProGuard etc on a library jar. And yet I hesitate…

    I understand that an internal API cannot be expected to be stable, but it looks like someone deliberately removed the “writeTo()” methods from previous releases. Is their existence in 1.2.30 an oversight, please? Or has JetBrains decided to allow (if not explicitly support) this operation now?

    Thanks,
    Chris

  9. Chris Rankin says:

    The file kotlin.reflect.jvm.internal.impl.serialization.ProtoBuf.java does not correspond to kotlin.reflect.jvm.internal.impl.serialization.ProtoBuf.class in kotlin-reflect, and I’m suspecting that is because you’ve used ProGuard to strip out the ProtoBuf functionality that is not exposed by Kotlin’s reflection API.

    Oh, the irony! I was hoping to be able to use ProtoBuf.java to rewrite the @kotlin.Metadata annotations in a “cut-down” (also by ProGuard) version of a Kotlin library of my own. Because if I leave the original @Metadata annotations in place then IntelliJ/Gradle allow me to compile against functions that no longer exist. (The code still fails at runtime, of course.) But if I strip the @Metadata annotations out instead then my library’s Kotlin features such as default parameter values, default interface functions and Companion objects etc are replaced with bad Java which is painful to develop against.

    This really isn’t ideal. It looks like my only remaining option is to copy the original ProtoBuf.java into my own source code under a different package name, and use that instead! Yikes!

    • Chris Rankin says:

      (OK, I have now discovered the org.jetbrains.kotlin.serialization.* classes inside kotlin-compiler-embeddable. These are probably the best solution I am going to find to my problem…)

Comments are closed.