JS: do not create variable for result, if inline call is only return subexpression
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package foo
|
||||
|
||||
// CHECK_CONTAINS_NO_CALLS: test
|
||||
// CHECK_VARS_COUNT: function=test count=0
|
||||
|
||||
inline fun sign(x: Int): Int {
|
||||
if (x < 0) return -1
|
||||
|
||||
if (x == 0) return 0
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
fun test(x: Int, y: Int): Int {
|
||||
if (x != 0) {
|
||||
return sign(x)
|
||||
}
|
||||
|
||||
return sign(y)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
assertEquals(-1, test(-2, 2))
|
||||
assertEquals(1, test(2, -2))
|
||||
assertEquals(-1, test(0, -2))
|
||||
assertEquals(1, test(0, 2))
|
||||
assertEquals(0, test(0, 0))
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user