JS: do not create var for result if statement is 'someVar = inlineCall()'

This commit is contained in:
Alexey Tsvetkov
2015-04-17 21:04:30 +03:00
parent fd09d4d837
commit c9b24510bb
4 changed files with 119 additions and 12 deletions
@@ -0,0 +1,22 @@
package foo
// CHECK_CONTAINS_NO_CALLS: test
// CHECK_VARS_COUNT: function=test count=1
inline fun sum(x: Int, y: Int): Int {
if (x == 0 || y == 0) return 0
return x + y
}
fun test(x: Int, y: Int): Int {
val sum: Int
sum = sum(x, y)
return sum
}
fun box(): String {
assertEquals(3, test(1, 2))
return "OK"
}
@@ -0,0 +1,21 @@
package foo
// CHECK_CONTAINS_NO_CALLS: test
// CHECK_VARS_COUNT: function=test count=1
inline fun sum(x: Int, y: Int): Int {
if (x == 0 || y == 0) return 0
return x + y
}
fun test(x: Int, y: Int): Int {
val sum = sum(x, y)
return sum
}
fun box(): String {
assertEquals(3, test(1, 2))
return "OK"
}