We’re happy to announce the release of a new bugfix and tooling update of Kotlin, version 1.0.4. This version brings many improvements related to the IDE and build tools, as well as JavaScript support.
Once again we’d like to thank our external contributors who implemented some of the features in this release, Kirill Rakhman and Yoshinori Isogai, as well as everyone who tried the EAP builds of 1.0.4 and sent us feedback.
You can find the full list of fixes and improvements in the changelog. Some of the changes deserve special mention:
Language Change: Assignment of ‘val’ in try/catch
In versions of Kotlin before 1.0.4, you could initialize the same val both in the try and catch branches of a try/catch statement. For example, the following code was allowed:
|
|
val x: Int try { x = 1 } catch(e: Exception) { x = 2 } |
In effect, a final variable could be assigned twice, and it was possible to observe two different values for it (for example, if the value in the try statement was captured in a lambda). In Java, the equivalent code is not allowed.
To maintain consistent semantics, the code which assigns the same val in both try and catch branches becomes a warning in Kotlin 1.0.4 and will become an error in version 1.0.5. 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. The above example would be converted to:
|
|
val x = try { 1 } catch(e: Exception) { 2 } |
Continue reading →