JetBrains/kotlin — pull request #139 by tomhal (2012-11-08 08:57:21+00:00)
Title: Better translation of !! info Javascript

This contains a change in how !! expressions are translated into Javascript.

This Kotlin code:

public val element: Element = window.document.createElement(tag)!!

generated the following Javascript:
...
var tmp$0;
this.$element = (tmp$0 = window.document.createElement(this.get_tag())) !== null && tmp$0 !== undefined ? tmp$0 : Kotlin.throwNPE();
...

After this patch the following will be generated:

this.$element = Kotlin.ensureNotNull(window.document.createElement(this.get_tag())))

Pavel correctly pointed out that ensureNotNull only checked for Javascript null and not also undefined as the previous generated code did. This is fixed as well in this patch.

This patch is related to: http://youtrack.jetbrains.com/issue/KT-2976