Kotlin 1.5.30 Is Now Available!
Since Kotlin 1.5.30 is the last incremental release before Kotlin 1.6.0, it includes many experimental language and standard library features that we are planning to release in Kotlin 1.6.0. Give them a try and share your feedback with us, you can really influence the final result! These experimental features include sealed
when statements, changes to opt-in requirements, instantiation of annotation classes, improvements to the
Regex stdlib APIs, and more.
With Kotlin 1.5.30, you can also enjoy native support for Apple silicon, the promotion of the Kotlin/JS IR backend to Beta, the ability to use custom
cinterop libraries in the shared native code of multiplatform applications, support for Java toolchains provided by the Kotlin Gradle plugin, and much more.
This blog post provides an overview of the updates in this release:
- Language improvements, including sealed
whenstatements, support for
suspendfunctions as supertypes, and changes to opt-in requirements.
- Multiplatform improvements, including the ability to use custom
cinteroplibraries in shared native code and support for XCFrameworks as an output format.
- Kotlin/JVM improvements, including instantiation of annotation classes and improved configuration of nullability annotation support.
- Kotlin/Native improvements, including native support for Apple silicon and an improved Kotlin DSL for the CocoaPods Gradle plugin.
- Kotlin/JS IR improvements, including the promotion of the JS IR backend to Beta and a better debugging experience for the new backend.
- Gradle improvements, including support for Java toolchains and easier ways to explicitly set the Kotlin daemon’s JVM arguments.
- Standard library improvements for the
Automatically update to Kotlin 1.5.30
If you use IntelliJ IDEA or Android Studio, you have the option to automatically update to the new Kotlin release as soon as it becomes available.
Learn more about installing Kotlin 1.5.30.
Note: the latest version of IntelliJ IDEA – 2021.2 – doesn’t support Kotlin 1.5.30. If you have already upgraded, you can easily install IntelliJ IDEA 2021.1 using the JetBrains Toolbox App and use Kotlin 1.5.30 in that version, or you can wait for the Kotlin 1.5.31 bug-fix release.
The Kotlin roadmap includes adding support for sealed
when statements, releasing opt-in annotations, improving type inference, and stabilizing builder inference.
Kotlin 1.5.30 takes a step down this road by providing a preview of these features, whose release is planned for 1.6.0.
when is a long awaited feature with more than 280 votes in YouTrack. If you enable this feature in 1.5.30, the Kotlin compiler will warn if one of your
when statements is not exhaustive. This will make your code safer without you having to introduce your own functions.
Give this feature a try and provide your feedback in this YouTrack ticket.
suspend functions as supertypes
Kotlin 1.5.30 provides a preview of an ability to use
suspend functional types as super interfaces, although it has some limitations. It’s one of the missing pieces in the Kotlin coroutines design.
Enable this feature, give it a try, and provide your feedback in this YouTrack ticket.
Changes to opt-in requirements
As a further step toward the release of opt-in annotations, Kotlin 1.5.30:
- Presents new rules for using and declaring opt-in requirement annotations on different targets.
- Requires opt-in even for implicit usages of an experimental API. For example, if the function’s return type is marked as an experimental API element, a usage of the function requires you to opt-in even if the declaration is not marked as requiring an opt-in explicitly.
Try out the changes and share your feedback in this YouTrack ticket.
Learn more about opt-in requirements.
Improvements to type inference on recursive generic types
With type inference on recursive generic types enabled, the Kotlin 1.5.30 compiler can infer a type argument based only on the upper bounds of the corresponding type parameter if it is a recursive generic. This makes it possible to create various patterns with recursive generic types that are often used in Java to make builder APIs.
Eliminating builder inference restrictions
With eliminating builder inference restrictions enabled, Kotlin 1.5.30 removes a builder inference restriction. Not only can you specify the type information that builder inference can infer, but you can also use the
get function on it. For example, you can call
get() inside a lambda argument of
buildList() without explicitly specified type arguments.
Kotlin 1.5.30 includes the following improvements for Kotlin Multiplatform:
- Ability to use custom
cinteroplibraries in shared native code, which extends the ability to share platform-dependent libraries shipped with Kotlin/Native.
- Support for XCFrameworks as an output format for all Kotlin Multiplatform projects. XCFrameworks help gather logic for all the target platforms and architectures in a single bundle and don’t require removing unnecessary architectures before publishing the application to AppStore.
- New default publishing setup for Android artifacts. This setup will be compatible with any build type (like
release) by default. Before 1.5.30, the metadata generated by the
maven-publishGradle plugin when publishing a multiplatform library for Android included the build type attribute for every published Android variant. This made it compatible only with the same build type used by the library consumer.
With Kotlin 1.5.30, Kotlin/JVM gets the following updates:
- Improved nullability annotation support configuration. You can specify whether the compiler reports a nullability mismatch based on information from specific types of nullability annotations. Learn how to enable this improvement and see the full list of supported nullability annotations, which has been extended with RxJava3 annotations.
- Instantiation of annotation classes. If you enable this feature, you can call constructors of annotation classes in arbitrary code to obtain a resulting instance. This feature covers the same use cases as the Java convention, which enables the implementation of an annotation interface. Learn more about instantiation of annotation classes in this KEEP.
Kotlin 1.5.30 provides the following improvements for Kotlin/Native:
- Native support for Apple silicon. You can now build applications on Apple silicon hardware for all targets that are supported on Intel-based Macs, without having to use the Rosetta translation environment. New targets introduced in 1.5.30 –
tvosSimulatorArm64– make it possible to run Kotlin code on Apple silicon natively.
- Improved Kotlin DSL for the CocoaPods Gradle plugin. Kotlin 1.5.30 improves CocoaPods configuration by providing a new DSL format for frameworks that is identical to a framework definition for Apple targets. You can define whether it is a static or dynamic type, enable the explicit export of dependencies and the Bitcode embedding, and configure other options.
- Experimental interoperability with Swift 5.5 async/await. Learn more about the current state of Swift 5.5 interoperability and leave your feedback in this YouTrack issue.
- Deprecation of linkage to DLLs without import libraries for MinGW (Windows). This deprecation is the result of the switch to the LLD linker, which has better performance and other improvements. Feel free to share your thoughts and concerns about the transition to the LLD linker in this YouTrack issue.
- Improved Swift/Objective-C mapping for objects and companion objects. Now you can access objects and companion objects in a way that’s more intuitive for native iOS developers – using the
Kotlin 1.5.30 provides the following improvements for Kotlin/JS:
- JS IR compiler backend reaches Beta. To simplify migration to the new backend, you can use the migration guide and the new Kotlin/JS Inspection Pack IDE plugin, which guides you through the process of making the necessary changes directly in IntelliJ IDEA.
Kotlin 1.5.30 introduces the following features to improve the Kotlin Gradle plugin user experience:
- Support for Java toolchains. Gradle 6.7 introduced support for Java toolchains, which make it easy to select a JDK for project compilation. Just declare the version you need in the build script and Gradle does the rest, finding it on your host machine or even downloading and installing it if it’s not there yet. The Kotlin Gradle plugin supports Java toolchains for Kotlin/JVM compilation tasks. For Gradle versions 6.1-6.6, set a JDK home with the
- Easier ways to explicitly specify Kotlin daemon JVM arguments. If nothing is specified for the Kotlin daemon, it inherits arguments from the Gradle daemon. You can now also specify arguments for a specific task, as well as for the Kotlin extension, as a single line in
Kotlin 1.5.30 brings improvements to the standard library’s
Duration API improvements
As indicated in our libraries roadmap, we’re going to stabilize the Duration API in Kotlin 1.6.0, which means this is the last chance to give it a try and share your feedback with us on anything you’d like changed. We would appreciate your feedback in this KEEP.
Kotlin 1.5.30 provides a preview of API improvements. The output of
Duration.toString() is now more readable. For example,
15h 20m instead of the previous
A negative duration is now prefixed with a minus sign (
-), and it is surrounded by parentheses if it consists of multiple components:
This release also provides a preview of new functions for parsing Duration from String:
parse()parses Duration objects from strings formatted as Duration’s
toString()or from strings representing ISO 8601 durations (such as
parseIsoString()parses Duration objects from strings representing ISO 8601 durations.
*OrNull()counterparts for both functions.
Regex API improvements
Kotlin 1.5.30 provides new experimental functions for regular expressions:
matchesAt()checks whether a regex has a match in the specified position of a String.
matchAt()returns the match if one is found.
splitToSequence()is a lazy counterpart of
split(). It splits the string around matches of the given regex, but returns the result as a
Sequence. A similar function has also been added to
How to install Kotlin 1.5.30
If you already use IntelliJ IDEA or Android Studio, your IDE will suggest updating Kotlin to 1.5.30 automatically. You can also update manually by following these instructions.
You can download the latest versions of these IDEs to get extensive support for Kotlin:
- IntelliJ IDEA – for developing Kotlin applications for various platforms.
- Android Studio – for developing Android and cross-platform mobile applications.
Make sure that you have also updated the kotlinx libraries to compatible versions and specified version 1.5.30 of Kotlin in the build scripts of your existing projects.
If you need the command-line compiler, download it from the Github release page.
If you run into any problems
- Find help on Slack (get an invite).
- Report issues to our issue tracker, YouTrack.
Stay up to date with information about the latest Kotlin features! Subscribe to receive Kotlin updates by filling out the form to the right of this post.
Read and watch more
- What’s new in Kotlin 1.5.30 video
- What’s new in Kotlin 1.5.30 docs
- Kotlin 1.5.20 blog post
- Kotlin 1.5.0 blog post
- Kotlin roadmap
External contributors 👏👏👏
We’d like to thank all of our external contributors whose pull requests were included in this release:
Jinseong Jeon, pyos, Tianyu Geng, Mark Punzalan, Mads Ager, Ivan Gavrilovic, Steven Schäfer, Vladimir Ivanov, Hung Nguyen, Matthew Gharrity, Jiaxiang Chen, Ivan Kochurkin, Iaroslav Postovalov, Toshiaki Kameyama, Udi Cohen, Xin Wang, bracadabra
Subscribe to Blog updates
Thanks, we've got you!