We’re happy to announce the release of Kotlin 1.2.40, a new bugfix and tooling update for Kotlin 1.2! This update:
- Allows platform modules in experimental multiplatform projects to have more than one
- Enables support for
suspendparameters in inline functions;
@JvmDefaultannotation that makes interface methods
defaultin Java (experimental);
- Adds new inspections and intentions to the Kotlin IntelliJ plugin;
- Deprecates using short names of types brought into the scope through subtyping of companion objects, without qualifying or importing them;
- Fixes a lot of known issues in the compiler and the IDE plugin and provides performance improvements.
The update is compatible with all versions of IntelliJ IDEA from 2017.1 until 2018.1, as well as with Android Studio 3.0, 3.1, and 3.2 Canary.
We’d like to thank our external contributors whose pull requests were included in this release: Toshiaki Kameyama, Mikaël Peltier, Alexey Belkov, meztihn, Gaetan Zoritchak, Yoshinori Isogai, Cuihtlauac Alvarado, Egor Neliuba, Elifarley C., Felix Guo, Jake Wharton, Raluca Sauciuc, Renaud Paquay, Rodrigo B. de Oliveira, Valeriy Zhirnov, Yanis Batura, Yuta Sakata, Kenji Tomita, yukuku.
The complete list of changes in this release can be found in the changelog.
Improvements for multiplatform projects
This update brings several improvements for the experimental multiplatform projects feature.
Platform modules are now allowed to reuse the code and provide actual platform-specific implementations for declarations from more than one common module. This is done by adding multiple
expectedBy dependencies to the platform module, for example:
apply plugin: 'kotlin-platform-jvm'
expectedBy dependencies are still non-transitive, so if a common module, say,
app-common, depends on another one,
lib-common, then, in a platform module, you can either provide actual implementations for both, manually specifying the two as
expectedBy dependencies, or add an
expectedBy dependency on just
app-common and a compile dependency on an existing platform module for
Another improvement is the support for default parameters in
expect functions and constructors:
Note that default parameter values are only allowed in
expect declarations. Do not specify them for the
Crossinline suspend function parameters
The update enables support for inline function
crossinline parameters of
suspend function types, which can then be called inside nested suspending functions and lambdas:
Support declaring Java default interface methods
This release brings experimental support for generating default interface methods for the JVM target 1.8 and above. This feature is disabled by default, you can enable it by passing a compiler flag
-Xenable-jvm-default. Then an interface member with a body can be marked with the
@JvmDefault annotation (from the
Since this functionality is experimental in Kotlin 1.2.x, its design and implementation may change in future updates, including the compiler flag name.
Visibility restrictions for types brought into scope through companion objects subtyping
To provide smooth migration with respect to potentially breaking changes in Kotlin 1.3 regarding classifiers visible through companion objects, this update introduces deprecation warnings and migration tools in the IDE plugin.
Now, whenever a body of a type
Foo uses a short (non-qualified) type name that is declared in a supertype of
Foo‘s own companion object, or in the companion objects of
Foo‘s supertypes, as well as in the supertypes of these companion objects, without a proper import statement, a warning is issued with a quick-fix that adds the import. One example is:
In Kotlin 1.3, these short names are going to become invisible unless they are qualified or imported. The planned change has been tested on real projects with more than 1.5 million lines of Kotlin code in total, and the impact is expected to be minimal.
For detailed description and motivation of the change, see KT-21515.
IntelliJ IDEA plugin improvements
Intentions for adding and removing explicit return in a lambda
There’s a new intention for adding and removing explicit labeled return for the result expressions in lambdas:
Other changes in the IDE plugin
- New intentions for adding and removing annotation use-site targets;
- An inspection to highlight and remove unnecessary explicit companion object references;
- A lot of stability and performance improvements.
Changes in the compiler
The Kotlin 1.2.40 update fixes several known issues in the Kotlin compiler and includes performance improvements.
The code that the compiler generates is now more efficient in several cases, such as accessing private properties of companion objects, checking enum entries for equality, and comparing
Long numbers, thanks to our contributor Mikaël Peltier.
How to update
To update the plugin, use Tools → Kotlin → Configure Kotlin Plugin Updates and press the Check for updates now button. Also, don’t forget to update the compiler and standard library version in your Maven and Gradle build scripts.