From 17e7c269adcda376579c73fcb0aa67487951993e Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Thu, 30 Jun 2016 22:03:48 +0300 Subject: [PATCH] Minor: make tryInlined test not depend on 'Closeable.use' implementation. --- .../coercionToUnitOptimization/tryInlined.kt | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/compiler/testData/codegen/bytecodeText/coercionToUnitOptimization/tryInlined.kt b/compiler/testData/codegen/bytecodeText/coercionToUnitOptimization/tryInlined.kt index ce32924eb6e..424a364c5bd 100644 --- a/compiler/testData/codegen/bytecodeText/coercionToUnitOptimization/tryInlined.kt +++ b/compiler/testData/codegen/bytecodeText/coercionToUnitOptimization/tryInlined.kt @@ -1,10 +1,21 @@ // WITH_RUNTIME -import java.io.* - -fun test(r: Reader) { - val ss = hashSetOf() - r.useLines { it.forEach { ss.add(it) } } +fun test(list: List) { + val result = mutableListOf() + use1 { list.forEach { result.add(it) } } } -// 2 POP +inline fun use1(f: () -> T): T { + return use2(f) +} + +inline fun use2(f: () -> T): T { + try { + return f() + } + catch (e: Exception) { + throw e + } +} + +// 1 POP