Connect with us

What’s new in Kotlin 1.2.60? Cool Features Make it your Next Favourite Programming Language



What’s new in Kotlin 1.2.60? Cool Features Make it your Next Favourite Programming Language

What’s new in Kotlin 1.2.60? Cool Features Make it your Next Favourite Programming Language

First appeared in 2011, the statically-typed programming language Kotlin is now picking up speed – it is getting popular day-by-day. As per data and predictions, more than 20% of the applications built with Java before Google I/O 2017 are being built within Kotlin language. In future, it might even change how Java is used on the server. It is expected that Kotlin will surpass Java in December 2018.

Kotlin 1.2.60, the newest bugfix and tooling update for Kotlin 1.2 brings a lot of goodies, including optional expected annotations to multiplatform projects, experimental kapt mode aimed to speed up Gradle builds, new refactorings, inspections, and intentions to the IntelliJ IDEA plugin and more. Let’s take a look at what’s in this update.


What’s New in Kotlin 1.2.60?

Multiplatform projects update

Multiplatform projects are a new experimental feature in Kotlin 1.2, allowing you to reuse code between target platforms supported by Kotlin – JVM, JavaScript and (in the future) Native.

Optional expectation for annotations

Kotlin 1.2.60 adds the @OptionalExpectation annotation, which will come in handy when marking expect annotation class declarations in common code whose actual counterparts may be omitted in the platform implementations. This will make the compiler ignore the annotations on the common declarations during compilation of the platform modules that have no corresponding actual annotation class, according to the blog post announcing the new update.

The biggest benefit is that you will be able to use annotations such as @JvmName and @JsName in common code of a multi-platform project. These annotations will be offered in kotlin-stdlib-common starting with 1.2.70.

Building a multi-platform project with IntelliJ IDEA

You can build a multiplatform project with the integrated build system of IntelliJ IDEA without delegating the task to Gradle, thus improving build times for IDE run configurations. These builds already benefit from incremental compilation of Kotlin code.

Kapt improvements

There’s now an experimental option to run kapt, the Kotlin annotation processing tool, directly using Gradle workers. In some cases, this may significantly improve the overall build speed.

If you want to switch to the Gradle worker implementation, all you have to do is add the kapt.use.worker.api=true key to the file. However, this is only available with Gradle 4.3 and above. The team plans to enable it by default in Kotlin 1.2.70, so make sure to give them your feedback.

Furthermore, information messages produced by the annotation processors used with kapt, which were shown as warnings in Gradle builds, are now printed with the INFO logging level for cleaner build outputs. If you’d like to revert to the old behavior and print them as warnings, you need to set the Gradle project property to true in the file.

IntelliJ IDEA support improvements

  • There’s a new quick fix for wrapping a value into a singleton list, set, array, or sequence on type mismatch and corresponding postfix templates for the functions listOf, setOf, arrayOf, sequenceOf
  • A quick fix for removing the lateinit modifier when it conflicts with a custom property accessor
  • A quick fix to either move a const val property into the companion object or remove an illegal const modifier
  • An intention for replacing String.format(…) with a string template
  • Other useful inspections and intentions
  • Lots of bug fixes and performance improvements

New Deprecations

New checks were added for the following erroneous constructs:

  • Smart casts of local delegated properties that led to type safety guarantees violation and runtime failures (KT-22517)
  • Annotation arguments erroneously accepted even though they are not compile time constants (KT-23153)
  • Java static member usages that were inconsistent with Kotlin companion object members visibility (KT-25333)
  • Annotations with EXPRESSION target and non-SOURCE retention (KT-13762)

Keep in mind that the above-mentioned deprecations are reported as warnings in Kotlin 1.2.60+ and will become errors in Kotlin 1.3. The corresponding checks already report errors in the progressive compiler mode (with the -Xprogressive flag).

To update your IntelliJ IDEA or Android Studio plugin, use Tools | Kotlin | Configure Kotlin Plugin Updates and click the “Check for updates now” button. You’ll also have to update the compiler and standard library version in your Maven and Gradle build scripts.

Continue Reading
You may also like...
Kiara Matthews

Kiara has spent 7+ years serving as the Digital Sales Manager. She loves getting to know the story behind a business and using that unique history to help a company succeed.

Click to comment

Leave a Reply

Your email address will not be published. Required fields are marked *

More in Programming

To Top