days
-4
-4
hours
0
-1
minutes
-3
-1
seconds
-2
-2
search
Polishing the key focus areas

Kotlin 1.1 Beta 2 is out

JAX Editorial Team

Kotlin 1.1 will soon be upon us — it reached beta on January 19 and now the second beta is here. Although this one is focused on improving the key focus areas of this release, namely coroutine support and the JavaScript backend, that’s not all.

Since the first beta release of Kotlin 1.1, the team at JetBrains has been focused on “stability, bugfixes, and improving the key focus areas of this release: coroutine support and the JavaScript backend.”

What’s new in beta 2?

According to the official announcement, for JavaScript projects, the name of the artifact for the standard library has been changed. kotlin-js-library is now kotlin-stdlib-js. Users will have to update their Maven and Gradle scripts accordingly when they update to 1.1 beta 2 or a newer build.

Furthermore, testing support classes (in the package kotlin.test) for JavaScript are now packaged as a separate artifact. If you’re using kotlin.test in your JS project, add a dependency on kotlin-test-js.

The coroutines APIs in the Kotlin standard library have been moved to the kotlin.coroutines.experimental package. People who have used these APIs in their code are advised to update their imports. For more details about this change, check out this forum post.

The team also made it easier to enable the experimental coroutine support in your Gradle projects. Instead of editing gradle.properties, you can add the following snippet to your build.gradle:

kotlin {
    experimental {
        coroutines 'enable'
    }
}

Those who are using the kotlinx.coroutines library are advised to update their dependency to version 0.6-beta because earlier versions of the library are incompatible with this Kotlin update.

SEE ALSO: What Kotlin is all about — As explained by Hadi Hariri

Kotlin 1.1 beta 2 overview

New features

The most important features of the second beta are the following:

  • The compiler now reports a warning if you declare an extension that has the same signature as a member of the same class and will always be shadowed (for example, String.length())
  • Type inference for member references passed to generic functions is now much improved (KT-10711)
  • The minus operator can now be used with maps, returning a copy of the map with the given keys removed. The -= operator can be used on mutable maps to remove the given keys from the map.
  • It is now possible to access the delegate instance of a delegated property using KPropertyN.getDelegate() (see KT-8384 for details);
  • Intention (contributed by Kirill Rakhman) to merge two nested if statements;
  • Support for building Android projects when the Jack toolchain is enabled (jackOptions { true });
  • Intention (contributed by Kirill Rakhman) to generate View constructors in Android applications.

Source compatibility with Kotlin 1.0

This allows you to try Kotlin 1.1, even if your team is using Kotlin 1.0, without worrying that you’ll break the build by using some of the features added in the new release, according to the official announcement.To enable the compatibility mode:

  • For Maven, Ant and the command-line compiler, set the -language-version compiler argument to 1.0.
  • In a Gradle build, add kotlinOptions { languageVersion = "1.0" } to your compileKotlin task.
  • In the IDE, specify the language version in the Kotlin facet settings or in Settings | Build, Execution, Deployment | Compiler | Kotlin Compiler

The complete list of changes can be found here.

Leave a Reply

Be the First to Comment!

avatar
400
  Subscribe  
Notify of