Minor: make tryInlined test not depend on 'Closeable.use' implementation.
This commit is contained in:
+17
-6
@@ -1,10 +1,21 @@
|
|||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
|
|
||||||
import java.io.*
|
fun test(list: List<String>) {
|
||||||
|
val result = mutableListOf<String>()
|
||||||
fun test(r: Reader) {
|
use1 { list.forEach { result.add(it) } }
|
||||||
val ss = hashSetOf<String>()
|
|
||||||
r.useLines { it.forEach { ss.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
|
||||||
|
|||||||
Reference in New Issue
Block a user