Make nullable check less verbose in JS-backend.

For check what variable is equal null or undefined enough to compare with null (or undefined).
See ECMAScript specification 11.9.1, 11.9.2, 11.9.3
This commit is contained in:
Zalim Bashorov
2013-06-04 16:06:41 +04:00
parent 60a2f4ef08
commit 2bae647412
5 changed files with 32 additions and 14 deletions
@@ -0,0 +1,18 @@
package foo
fun box() : String {
val a: Int? = null
val r = a == null
if (!r || a != null)
return "wrong result on simple nullable check"
var i = 0;
fun foo(): Int? = ++i;
if (foo() == null)
return "wrong result on nullable check with side effects"
if (i != 1)
return "wrong affects when using nullable check with side effects"
return "OK"
}