Files
kotlin-fork/js/js.translator/testData/box/inline/safeCall.kt
T
Alexey Andreev 3b3fd0fa0d JS: fix DCE limits in test data to fit new kotlin.js size
The size has increased due to new implementation of KClass
2017-10-06 18:16:51 +03:00

16 lines
316 B
Kotlin
Vendored

// EXPECTED_REACHABLE_NODES: 1113
package foo
// CHECK_CONTAINS_NO_CALLS: sum
inline fun <T : Any, R> T.doLet(f: (T) -> R): R = f(this)
private fun sum(x: Int?, y: Int): Int =
x?.doLet { it + y } ?: 0
fun box(): String {
assertEquals(5, sum(2, 3))
assertEquals(0, sum(null, 3))
return "OK"
}