Do not restore stack in default handler for try-finally

It never terminates, so the corresponding value on stack can't be used.
However, if this happens in an inlined lambda argument, the inliner is
unable to remove the corresponding ALOAD instruction (because default
handler never terminates, and thus corresponding ALOAD is not used for
lambda invocation).

KT-17573 try-finally expression in inlined function parameter argument fails with VerifyError
This commit is contained in:
Dmitry Petrov
2017-04-25 12:25:32 +03:00
parent e91f4cf65a
commit e1731373d8
8 changed files with 83 additions and 4 deletions
@@ -0,0 +1,6 @@
fun zap(s: String) = s
inline fun tryZap(string: String, fn: (String) -> String) =
fn(try { zap(string) } finally {})
fun box(): String = tryZap("OK") { it }
@@ -0,0 +1,17 @@
fun zap(s: String) = s
inline fun tryZap1(string: String, fn: (String) -> String) =
fn(
try { zap(string) } finally {
try { zap(string) } finally { }
}
)
inline fun tryZap2(string: String, fn: (String) -> String) =
fn(
try { zap(string) } finally {
try { zap(string) } catch (e: Exception) { }
}
)
fun box(): String = tryZap1("O") { it } + tryZap2("K") { it }