Minor: make tryInlined test not depend on 'Closeable.use' implementation.

This commit is contained in:
Ilya Gorbunov
2016-06-30 22:03:48 +03:00
parent 24ad167b9d
commit 17e7c269ad

View File

@@ -1,10 +1,21 @@
// WITH_RUNTIME
import java.io.*
fun test(r: Reader) {
val ss = hashSetOf<String>()
r.useLines { it.forEach { ss.add(it) } }
fun test(list: List<String>) {
val result = mutableListOf<String>()
use1 { list.forEach { result.add(it) } }
}
// 2 POP
inline fun <T> use1(f: () -> T): T {
return use2(f)
}
inline fun <T> use2(f: () -> T): T {
try {
return f()
}
catch (e: Exception) {
throw e
}
}
// 1 POP