From 57f8f216d19c4eef40afb49753f6449e493c4017 Mon Sep 17 00:00:00 2001 From: Alexey Tsvetkov Date: Tue, 11 Dec 2018 22:42:37 +0300 Subject: [PATCH] Exclude local variables and try catch blocks of non-inline functions from ABI --- .../kotlin/jvm/abi/asm/ReplaceWithEmptyMethodVisitor.kt | 2 ++ .../testData/compare/functionBody/base/function.kt | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/plugins/jvm-abi-gen/src/org/jetbrains/kotlin/jvm/abi/asm/ReplaceWithEmptyMethodVisitor.kt b/plugins/jvm-abi-gen/src/org/jetbrains/kotlin/jvm/abi/asm/ReplaceWithEmptyMethodVisitor.kt index 6f7e7f0e68e..a848e1da743 100644 --- a/plugins/jvm-abi-gen/src/org/jetbrains/kotlin/jvm/abi/asm/ReplaceWithEmptyMethodVisitor.kt +++ b/plugins/jvm-abi-gen/src/org/jetbrains/kotlin/jvm/abi/asm/ReplaceWithEmptyMethodVisitor.kt @@ -19,5 +19,7 @@ internal class ReplaceWithEmptyMethodVisitor( ) : TransformationMethodVisitor(delegate, access, name, desc, signature, exceptions, api = ABI_EXTENSION_ASM_API_VERSION) { override fun performTransformations(methodNode: MethodNode) { methodNode.instructions.clear() + methodNode.localVariables.clear() + methodNode.tryCatchBlocks.clear() } } \ No newline at end of file diff --git a/plugins/jvm-abi-gen/testData/compare/functionBody/base/function.kt b/plugins/jvm-abi-gen/testData/compare/functionBody/base/function.kt index fe4bce1841c..46c201a8e7e 100644 --- a/plugins/jvm-abi-gen/testData/compare/functionBody/base/function.kt +++ b/plugins/jvm-abi-gen/testData/compare/functionBody/base/function.kt @@ -1,3 +1,10 @@ package test -fun sum(x: Int, y: Int): Int = x + y \ No newline at end of file +fun sum(x: Int, y: Int): Int = + try { + var result = x + result += y + result + } finally { + // do nothing + } \ No newline at end of file