Kotlin 1.7.0 beta alters builder type inference

A new memory manager is also featured in the planned language upgrade.

Kotlin 1.7.0 beta alters builder type inference
Matthew Kerslake (CC0)

Kotlin 1.7.0, a planned new version of JetBrains’ cross-platform, multipurpose programming language, has reached a beta release stage, featuring changes to the builder type inference and a new memory manager.

Builder inference, a special kind of type inference useful when calling generic builder functions, brings the platform closer to builder inference stabilization. With the 1.7.0 beta, builder inference is automatically activated if a regular type inference cannot get enough information about a type without specifying the -Xenable-builder-inference compiler option. Developers now can write their own builders that use builder type inference without applying additional annotations or options. Builder type inference helps the compiler infer the type arguments via type information about other calls inside a lambda argument.

Also in the beta, an alpha version of a new Kotlin/Native memory manager is featured, bringing performance improvements to better the developer experience. The manager eliminates differences between the JVM and Native platforms. Developers will have an easier time building cross-platform mobile applications that work on both Android and iOS, according to JetBrains. Also, restrictions are removed on object-sharing between threads, and leak-free concurrent programming primitives are provided that do not require special management or annotations. The new memory manager will become the default in future versions.

Instructions on installing Kotlin 1.7.0 beta can be found at blog.jetbrains.com. Other features in the beta include:

  • Stabilizing of definitely non-nullable types, introduced in Kotlin 1.6.20 last month and now enabled by default. This gives developers types for better interoperability when extending generic Java classes and interfaces.
  • Original function names are reintroduced for min() and max() collection functions. These had been renamed in Kotlin 1.4 to minOrNull() and maxOrNull(), to better reflect behavior returning null if the receiver collection is empty and to help align the functions’ behavior with naming conventions used in the Kotlin collections API. The new beta reintroduces the original function names but with a non-nullable return type.
  • Group names can be used when backreferencing groups.
  • Named group references can be used with replacement expressions.
  • Starting with the 1.7.0 beta, cadence terminology has been updated by changing “Milestone” to “Beta.”

Copyright © 2022 IDG Communications, Inc.