From 0020e953e10881ee509b22dfb6239fbd7d69c781 Mon Sep 17 00:00:00 2001 From: Jiaxiang Chen Date: Fri, 3 May 2019 17:37:49 -0700 Subject: [PATCH] Change order of line number geneartion for function call, and also force line number generation after visiting inline functions. --- .../kotlin/backend/jvm/codegen/ExpressionCodegen.kt | 6 ++++-- compiler/testData/codegen/box/smap/chainCalls.kt | 1 - compiler/testData/codegen/box/smap/infixCalls.kt | 1 - compiler/testData/codegen/box/smap/simpleCallWithParams.kt | 1 - 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt index 142767bbfb0..fb4f12822b7 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt @@ -268,7 +268,6 @@ class ExpressionCodegen( visitStatementContainer(expression, data).coerce(expression.asmType) override fun visitFunctionAccess(expression: IrFunctionAccessExpression, data: BlockInfo): PromisedValue { - expression.markLineNumber(startOffset = true) classCodegen.context.irIntrinsics.getIntrinsic(expression.symbol) ?.invoke(expression, this, data)?.let { return it.coerce(expression.asmType) } @@ -353,6 +352,7 @@ class ExpressionCodegen( } } + expression.markLineNumber(true) callGenerator.genCall( callable, defaultMask.generateOnStackIfNeeded(callGenerator, callee is IrConstructor, this), @@ -1088,7 +1088,9 @@ class ExpressionCodegen( } override fun markLineNumberAfterInlineIfNeeded() { - //TODO + // Inline function has its own line number which is in a separate instance of codegen, + // therefore we need to reset lastLineNumber to force a line number generation after visiting inline function. + lastLineNumber = -1 } fun isFinallyMarkerRequired(): Boolean { diff --git a/compiler/testData/codegen/box/smap/chainCalls.kt b/compiler/testData/codegen/box/smap/chainCalls.kt index 5288fc1bc43..73da8b97720 100644 --- a/compiler/testData/codegen/box/smap/chainCalls.kt +++ b/compiler/testData/codegen/box/smap/chainCalls.kt @@ -84,4 +84,3 @@ fun String.fail(): String { fun call(): String { return "xxx" } -// IGNORE_BACKEND: JVM_IR \ No newline at end of file diff --git a/compiler/testData/codegen/box/smap/infixCalls.kt b/compiler/testData/codegen/box/smap/infixCalls.kt index aa9b77df5f1..eeab32d82e9 100644 --- a/compiler/testData/codegen/box/smap/infixCalls.kt +++ b/compiler/testData/codegen/box/smap/infixCalls.kt @@ -64,4 +64,3 @@ infix fun String.fail(p: String): String { fun call(): String { return "xxx" } -// IGNORE_BACKEND: JVM_IR \ No newline at end of file diff --git a/compiler/testData/codegen/box/smap/simpleCallWithParams.kt b/compiler/testData/codegen/box/smap/simpleCallWithParams.kt index 4aed93e4350..473fa927e1b 100644 --- a/compiler/testData/codegen/box/smap/simpleCallWithParams.kt +++ b/compiler/testData/codegen/box/smap/simpleCallWithParams.kt @@ -108,4 +108,3 @@ inline fun inlineFun(): String { fun fail(): String { throw AssertionError("fail") } -// IGNORE_BACKEND: JVM_IR \ No newline at end of file