JS backend: fix KT-6037 (default arguments in simple function with expression as body)

#KT-6037 Fixed
This commit is contained in:
Michael Nedzelsky
2014-10-16 20:37:35 +04:00
parent 954a011721
commit 34269e1a3e
3 changed files with 22 additions and 1 deletions
@@ -0,0 +1,17 @@
// KT-6037: KT-6037 Javascript default function arguments fill code generated in wrong order on method without "return keyword"
package foo
inline fun id<T>(x: T) = x
fun test(arg: Int = 10) = id(arg)
fun foo(value: String = "K") = "O" + try { value } catch(e: Exception) { "..." }
fun box(): String {
assertEquals(10, test())
assertEquals(100, test(100))
assertEquals("OK", foo())
return "OK"
}