diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java index 0f6f65eb51a..7abf69564b4 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java @@ -742,7 +742,11 @@ public class ExpressionCodegen extends KtVisitor impleme // Some forms of for-loop can be optimized as post-condition loops. PseudoInsnsKt.fakeAlwaysFalseIfeq(v, continueLabel); + // Renew line number cause it could be reset by inline (resetLastLineNumber) in generator.checkPreCondition(loopExit). + markStartLineNumber(generator.getForExpression()); + v.nop(); generator.beforeBody(); + blockStackElements.push(new LoopBlockStackElement(loopExit, continueLabel, targetLabel(generator.getForExpression()))); generator.body(); blockStackElements.pop(); diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/ir/FirBlackBoxInlineCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/ir/FirBlackBoxInlineCodegenTestGenerated.java index 735807fe896..765f6d542d7 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/ir/FirBlackBoxInlineCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/ir/FirBlackBoxInlineCodegenTestGenerated.java @@ -3551,6 +3551,11 @@ public class FirBlackBoxInlineCodegenTestGenerated extends AbstractFirBlackBoxIn runTest("compiler/testData/codegen/boxInline/smap/defaultFunctionWithInlineCall.kt"); } + @TestMetadata("forInline.kt") + public void testForInline() throws Exception { + runTest("compiler/testData/codegen/boxInline/smap/forInline.kt"); + } + @TestMetadata("interleavedFiles.kt") public void testInterleavedFiles() throws Exception { runTest("compiler/testData/codegen/boxInline/smap/interleavedFiles.kt"); diff --git a/compiler/testData/codegen/boxInline/smap/forInline.kt b/compiler/testData/codegen/boxInline/smap/forInline.kt new file mode 100644 index 00000000000..67840ef676f --- /dev/null +++ b/compiler/testData/codegen/boxInline/smap/forInline.kt @@ -0,0 +1,61 @@ +// !LANGUAGE: +CorrectSourceMappingSyntax +// WITH_RUNTIME +// FILE: 1.kt +package test + +inline fun stub() { + +} + +// FILE: 2.kt + +fun box(): String { + //Breakpoint! + for (element in Some()) { // No inlining visible on this string + return nonInline(element) + } + return "fail" +} + +fun nonInline(p: T): T = p + +class Some() { + operator fun iterator() = SomeIterator() +} + +class SomeIterator { + var result = "OK" + + inline operator fun hasNext() : Boolean { + return result == "OK" + } + + inline operator fun next(): String { + result = "fail" + return "OK" + } +} + + +// FILE: 1.smap + +// FILE: 2.smap +SMAP +2.kt +Kotlin +*S Kotlin +*F ++ 1 2.kt +_2Kt ++ 2 2.kt +SomeIterator +*L +1#1,31:1 +21#2,6:32 +*S KotlinDebug +*F ++ 1 2.kt +_2Kt +*L +5#1:32,6 +*E \ No newline at end of file diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java index 08768c1d393..8452fce8d1b 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java @@ -3551,6 +3551,11 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo runTest("compiler/testData/codegen/boxInline/smap/defaultFunctionWithInlineCall.kt"); } + @TestMetadata("forInline.kt") + public void testForInline() throws Exception { + runTest("compiler/testData/codegen/boxInline/smap/forInline.kt"); + } + @TestMetadata("interleavedFiles.kt") public void testInterleavedFiles() throws Exception { runTest("compiler/testData/codegen/boxInline/smap/interleavedFiles.kt"); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java index cdc6c658f5b..84f33fa5110 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java @@ -3551,6 +3551,11 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi runTest("compiler/testData/codegen/boxInline/smap/defaultFunctionWithInlineCall.kt"); } + @TestMetadata("forInline.kt") + public void testForInline() throws Exception { + runTest("compiler/testData/codegen/boxInline/smap/forInline.kt"); + } + @TestMetadata("interleavedFiles.kt") public void testInterleavedFiles() throws Exception { runTest("compiler/testData/codegen/boxInline/smap/interleavedFiles.kt"); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java index a63eb5652e1..64d54213a38 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java @@ -3551,6 +3551,11 @@ public class IrBlackBoxInlineCodegenTestGenerated extends AbstractIrBlackBoxInli runTest("compiler/testData/codegen/boxInline/smap/defaultFunctionWithInlineCall.kt"); } + @TestMetadata("forInline.kt") + public void testForInline() throws Exception { + runTest("compiler/testData/codegen/boxInline/smap/forInline.kt"); + } + @TestMetadata("interleavedFiles.kt") public void testInterleavedFiles() throws Exception { runTest("compiler/testData/codegen/boxInline/smap/interleavedFiles.kt"); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstInlineKotlinTestGenerated.java index 057a0ec17ef..e3e8f6f2da4 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstInlineKotlinTestGenerated.java @@ -3551,6 +3551,11 @@ public class IrCompileKotlinAgainstInlineKotlinTestGenerated extends AbstractIrC runTest("compiler/testData/codegen/boxInline/smap/defaultFunctionWithInlineCall.kt"); } + @TestMetadata("forInline.kt") + public void testForInline() throws Exception { + runTest("compiler/testData/codegen/boxInline/smap/forInline.kt"); + } + @TestMetadata("interleavedFiles.kt") public void testInterleavedFiles() throws Exception { runTest("compiler/testData/codegen/boxInline/smap/interleavedFiles.kt"); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/JvmIrAgainstOldBoxInlineTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/JvmIrAgainstOldBoxInlineTestGenerated.java index e53ac975c9e..9e053a8c5dc 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/JvmIrAgainstOldBoxInlineTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/JvmIrAgainstOldBoxInlineTestGenerated.java @@ -3551,6 +3551,11 @@ public class JvmIrAgainstOldBoxInlineTestGenerated extends AbstractJvmIrAgainstO runTest("compiler/testData/codegen/boxInline/smap/defaultFunctionWithInlineCall.kt"); } + @TestMetadata("forInline.kt") + public void testForInline() throws Exception { + runTest("compiler/testData/codegen/boxInline/smap/forInline.kt"); + } + @TestMetadata("interleavedFiles.kt") public void testInterleavedFiles() throws Exception { runTest("compiler/testData/codegen/boxInline/smap/interleavedFiles.kt"); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/JvmOldAgainstIrBoxInlineTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/JvmOldAgainstIrBoxInlineTestGenerated.java index 0833aee391a..b3298bf657d 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/JvmOldAgainstIrBoxInlineTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/JvmOldAgainstIrBoxInlineTestGenerated.java @@ -3551,6 +3551,11 @@ public class JvmOldAgainstIrBoxInlineTestGenerated extends AbstractJvmOldAgainst runTest("compiler/testData/codegen/boxInline/smap/defaultFunctionWithInlineCall.kt"); } + @TestMetadata("forInline.kt") + public void testForInline() throws Exception { + runTest("compiler/testData/codegen/boxInline/smap/forInline.kt"); + } + @TestMetadata("interleavedFiles.kt") public void testInterleavedFiles() throws Exception { runTest("compiler/testData/codegen/boxInline/smap/interleavedFiles.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenInlineES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenInlineES6TestGenerated.java index 588bcf36a64..a1d8520d3d9 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenInlineES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenInlineES6TestGenerated.java @@ -3151,6 +3151,11 @@ public class IrJsCodegenInlineES6TestGenerated extends AbstractIrJsCodegenInline runTest("compiler/testData/codegen/boxInline/smap/defaultFunctionWithInlineCall.kt"); } + @TestMetadata("forInline.kt") + public void testForInline() throws Exception { + runTest("compiler/testData/codegen/boxInline/smap/forInline.kt"); + } + @TestMetadata("interleavedFiles.kt") public void testInterleavedFiles() throws Exception { runTest("compiler/testData/codegen/boxInline/smap/interleavedFiles.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java index 4e068f7f7f6..8e2b513129f 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java @@ -3151,6 +3151,11 @@ public class IrJsCodegenInlineTestGenerated extends AbstractIrJsCodegenInlineTes runTest("compiler/testData/codegen/boxInline/smap/defaultFunctionWithInlineCall.kt"); } + @TestMetadata("forInline.kt") + public void testForInline() throws Exception { + runTest("compiler/testData/codegen/boxInline/smap/forInline.kt"); + } + @TestMetadata("interleavedFiles.kt") public void testInterleavedFiles() throws Exception { runTest("compiler/testData/codegen/boxInline/smap/interleavedFiles.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java index e928f203178..11821520f20 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java @@ -3151,6 +3151,11 @@ public class JsCodegenInlineTestGenerated extends AbstractJsCodegenInlineTest { runTest("compiler/testData/codegen/boxInline/smap/defaultFunctionWithInlineCall.kt"); } + @TestMetadata("forInline.kt") + public void testForInline() throws Exception { + runTest("compiler/testData/codegen/boxInline/smap/forInline.kt"); + } + @TestMetadata("interleavedFiles.kt") public void testInterleavedFiles() throws Exception { runTest("compiler/testData/codegen/boxInline/smap/interleavedFiles.kt");