Merge pull request #500 from MichaelNedzelsky/kt5320

JS Backend: fixed associativity of JsCondition(ternary operator).

Fixed wrong code generation when use JsCondition(ternary operator) as condition of simple `if`(JsCondition).

#KT-5320 fixed
This commit is contained in:
Zalim Bashorov
2014-07-22 15:17:43 +04:00
3 changed files with 25 additions and 3 deletions
@@ -0,0 +1,14 @@
// http://youtrack.jetbrains.com/issue/KT-5320
// KT-5320 Invalid JS code generated for typecast inside ternary operator
package foo
fun test(x: Any?): Int = if (x as Boolean) 1 else 2;
fun box(): String {
assertEquals(1, test(true), "true")
assertEquals(2, test(false), "false")
assertEquals("OK", if (if (0 < 1) false else true) "Not OK" else "OK")
return "OK"
}