Kotlin 1.0.4: New bugfix and tooling update
You can find the entire list of fixes and improvements here.
Changes in Kotlin 1.0.4
In previous versions, users could initialize the same
val both in the
catchbranches of a
try/catch statement. Jemerov explained that a final variable could be assigned twice, and it was possible to observe two different values for it.
This is what happens in Kotlin 1.0.4: To preserve consistent semantics, the code which assigns the same
val in both
catch branches becomes a warning. Furthermore, it will become an error in the next version. “In most cases, the code can be easily fixed by converting the code to an expression form, and the IDE will offer a quickfix to convert this code automatically.”
This version also introduces a new experimental implementation of the annotation processing API. Add the following to your build.gradle if you want to enable it:
apply plugin: 'kotlin-kapt'
You will also have to remove the snippet that enables old annotation processing:
There are still known issues in the new annotation processing and may not be compatible with all annotation processors. Jemerov warned that you should enable it only if you’ve run into problems with the default
kapt annotation processing implementation.
jsClass property to access the runtime class of any object and
jsClass<TypeName>() to get the runtime representation of a specific class.
Compiler, build tools improvements
There is a better type inference for callable expressions, as well as better parser recovery after syntax errors. Kotlin 1.0.4 contains more efficient bytecode for several cases of
for expressions and there are fixed several cases when “Cast never succeeds” warning was incorrectly reported.
There is now full compatibility with Gradle 2.14 and later and Gradle incremental compilation can now track changes between subprojects. Plus, CLI and Ant builds add the Kotlin reflection library to the classpath by default; you can use the
no-reflect switch to disable.
New features in the IDE
You have the option to use Kotlin syntax when evaluating expressions and watches in Java files and there’s a new inspection to detect “leaking
this” – possible NullPointerException issues caused by access to incompletely initialized data. A couple of other new features are the intention to convert a lambda to a function reference and the inspection to detect mismatches between Gradle version and Kotlin plugin version.