In Fall 2020, the Kotlin team announced that they are changing the regularity of releasing new features. Every Kotlin 1.X will now be released every 6 months. These releases will be date-driven, not feature-driven. The Kotlin IDE plugin will be published simultaneously as Kotlin, and also whenever IntelliJ IDEA is updated. Major IDE features will be available in IntelliJ IDEA-synchronized versions. Thus welcome to the first release Kotlin 1.5!

What are the most interesting new features and bug fixes in Kotlin 1.5?

Sealed interfaces

With that new feature, you can create sealed interfaces. What does it mean? All implementations of a sealed interface are known at compile time. Now the IDE will help us with writing exhaustive when expressions!

fun draw(polygon: Polygon) = when (polygon) {
   is Rectangle -> // ...
   is Triangle -> // …
   // else is not needed - all possible implementations are covered
}

Inline classes

Now we have to write value instead of inline for inline classes:

value class Password(val s: String)

Inline modifier is deprecated now.

Kotlin-1.5-Arrived

Coroutines changes

  • GlobalScope is now marked as a delicate API, meaning the compiler will warn about possible misuse
  • Added a CoroutinesTimeout annotation that allows running tests in a separate thread, failing them after the provided time limit and interrupting the thread
  • Channel API changes – Along with a new naming scheme for the library functions, the non-suspending functions trySend and tryReceive were introduced as better alternatives to offer and poll.
  • Added more functions for converting from Reactive Streams types to Kotlin Flow and back, stabilized many existing functions and ReactiveContext API.

kotlinx.serialization

  • Much faster encoding and decoding
  • Support for value classes
  • Support for unsigned integers
  • Alternative name support for JSON fields
@Serializable
data class Project(@JsonNames("title") val name: String)

Now name field supports both name and title as alternative json field name:

{"name":"kotlinx.serialization"}
/* ...or: */
{"title":"kotlinx.serialization"}

Both will work!

Parcelize bugfix for classes with generic types

We couldn’t use Parcelize for classes with generic types. Now we can!

Contact

Do you want to find out more about Kotlin?

Talk to us!

What to know about new versions of Kotlin? 

Major updates in the Kotlin IDE plugin are more reliant on the IntelliJ Platform than on the Kotlin compiler. As a result, new versions of the Kotlin plugin and new versions of Kotlin will be provided with every IntelliJ Platform update.

The two most recent versions of IntelliJ IDEA and the most current version of Android Studio will always have IDE support for the newest version of the language.

It is by removing all obstacles that Kotlin’s rapid development is possible. The development of this language directly affects its use by the whole community and all developers. If you want to know more about Kotlin’s plans, take a look at the recently published Kotlin roadmap or contact your best Android App Development Agencies.