Facilitating the Spread of Knowledge and Innovation in Professional Software Development



Choose your language

InfoQ Homepage News Kotlin 1.6.20 Brings Definitely Non-Nullable Types, Standalone Android Executables, and More

Kotlin 1.6.20 Brings Definitely Non-Nullable Types, Standalone Android Executables, and More

This item in japanese


Kotlin 1.6.20 brings many new features, including standalone Android executables, extended context receivers, native parallel compilation, definitely non-nullable types, and much more.

With version 1.6.20 the Kotlin compiler is able to create proper standard executables for Android Native targets, whereas it previously could only generate a shared library to be used as a NativeActivity. To enable this feature, you specify the following build.gradle option:

kotlin {
    androidNativeX64("android") {
        binaries {
            executable {
                binaryOptions["androidProgramType"] = "standalone"

This behaviour will be the default in Kotlin 1.7.

Context receivers are a mechanism to implicitly add a parameter to a function declaration. The implicit parameter is represented by a context prepended to the function signature which can later be passed in a with statement. Prior to Kotlin 1.6.20, only one context receiver could be specified for a given function. Kotlin 1.6.20 removes that limitation and enables the use of multiple context receivers. InfoQ already covered context receivers when Kotlin 1.6.20 became available as a beta, so you can refer to that article for additional details.

Definitely non-nullable types aim to improve interoperability with generic Java classes and interfaces. This new feature allows you to specify a generic type parameter is definitely non-nullable using the type T & Any (intersection of T and non-nullable Any). This is useful, for example, when you want to override a Java method taking a @NotNull argument, like in the following snippet:

// given this Java declaration:
// public interface A<T> {
//     public T foo(T x) { return x; }
//     @NotNull
//     public T bar(@NotNull T x) {}
// }

// you can derive from it in Kotlin using:
interface B<T1> : A<T1> {
    override fun foo(x: T1): T1
    override fun bar(x: T1 & Any): T1 & Any

Another area where Kotlin 1.6.20 brings significant improvements is better interoperability with Swift and ObjC and Xcode and a new CocoaPods Gradle plugin. Kotlin supports calling suspending functions from Swift and Objective-C code. With Kotlin 1.6.20 such functions can be called from Swift async functions with the proper nullability. The Kotlin CocoaPods Gradle plugin can be used to create the Podspec files necessary to integrate a Kotlin project with CocoaPods.

As a final note, Kotlin 1.6.20 also brings significant performance improvements, including support for parallel compilation of large monolithic modules, which are not parallelized by gradle; faster incremental compilation when building development binaries; faster execution and binary size reduction.

There is much more to Kotlin 1.6.20 than what can be covered here, so do not miss the official announcement for the full details.

About the Author

Rate this Article


Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p