JS: inline safe calls

#KT-6912 fixed
This commit is contained in:
Alexey Tsvetkov
2016-03-06 18:58:15 +03:00
parent 956e9f3847
commit df3f163ee2
4 changed files with 28 additions and 4 deletions
+15
View File
@@ -0,0 +1,15 @@
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"
}