JS backend: remove dangerous package, correct translation for call, assignments, binary operations, support try...catch as expression
#KT-5576 Fixed #KT-5594 Fixed #KT-3166 Fixed #KT-5545 Fixed #KT-5594 Fixed #KT-5258 Fixed JS backend: fix KT-4879: extra side effect when use when in default arguments #KT-4879 Fixed JS backend: improve and fix WhenTranslator, fix order of evaluation for condtitions, fix KT-5263 (JS: extra tmp when initialize val in when by expression with if) #KT-5263 Fixed
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
package foo
|
||||
|
||||
var sideEffect: Int = 0;
|
||||
|
||||
class A(val x: Int)
|
||||
|
||||
val global_a = A(1)
|
||||
val global_b = A(2)
|
||||
|
||||
fun nullFun(value: Boolean): Any? = if (value) null else global_a
|
||||
|
||||
fun box(): String {
|
||||
|
||||
nullFun(false) ?: global_b
|
||||
assertEquals(global_a, nullFun(false) ?: try { ++sideEffect; global_b } finally {}, "false, global_b")
|
||||
assertEquals(0, sideEffect, "false, global_b side effect")
|
||||
|
||||
assertEquals(global_b, nullFun(true) ?: try { ++sideEffect; global_b } finally {}, "true, global_b")
|
||||
assertEquals(1, sideEffect, "true, global_b side effect")
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user