From 7d7b9262e7d276d1c703771d1b134a5db23263fd Mon Sep 17 00:00:00 2001 From: Mads Ager Date: Tue, 26 May 2020 14:33:36 +0200 Subject: [PATCH] [JVM] Port remaining line number tests to stepping infrastructure. These line number tests only tested that a set of line numbers where present in the java bytecode. Not that they would be hit in the right order by the debugger. Moving them to stepping tests fixes that. This exposes a couple of issues (in particular around try-catch-finally) that should be fixed. A number of tests are marked as failing now. Will investigate and work on fixes next. --- .../debug/stepping/beforeGotoToWhileStart.kt | 36 ++++ .../debug/stepping/callWithCallInArguments.kt | 33 ++++ .../debug/stepping/callWithReceiver.kt | 28 +++ compiler/testData/debug/stepping/chainCall.kt | 30 +++ .../debug/stepping/compileTimeConstant.kt | 14 ++ .../debug/stepping/functionCallWithDefault.kt | 32 ++++ .../functionCallWithInlinedLambdaParam.kt | 31 ++++ .../stepping/functionCallWithLambdaParam.kt | 30 +++ compiler/testData/debug/stepping/ifThen.kt | 25 +++ .../testData/debug/stepping/ifThenElse.kt | 41 +++++ .../debug/stepping/ifThenElseFalse.kt | 36 ++++ .../inTheEndOfLambdaArgumentOfInlineCall.kt | 34 ++++ .../testData/debug/stepping/initBlocks.kt | 98 ++++++++++ .../debug/stepping/multilineFunctionCall.kt | 16 ++ .../debug/stepping/multilineInfixCall.kt | 16 ++ .../noParametersArgumentCallInExpression.kt | 20 ++ .../debug/stepping/primitiveNullChecks.kt | 12 ++ .../debug/stepping/smapInlineAsArgument.kt | 38 ++++ .../stepping/smapInlineAsInfixArgument.kt | 36 ++++ .../stepping/smapInlineAsInlineArgument.kt | 38 ++++ .../stepping/smapInlineInIntrinsicArgument.kt | 37 ++++ .../debug/stepping/tryCatchExpression.kt | 73 ++++++++ .../debug/stepping/tryCatchFinally.kt | 96 ++++++++++ .../testData/debug/stepping/tryFinally.kt | 70 +++++++ compiler/testData/debug/stepping/when.kt | 98 ++++++++++ .../testData/debug/stepping/whenSubject.kt | 94 ++++++++++ .../custom/beforeGotoToWhileStart.kt | 13 -- .../custom/callWithCallInArguments.kt | 17 -- .../lineNumber/custom/callWithReceiver.kt | 15 -- .../testData/lineNumber/custom/chainCall.kt | 15 -- .../lineNumber/custom/compileTimeConstant.kt | 6 - .../custom/functionCallWithDefault.kt | 12 -- .../functionCallWithInlinedLambdaParam.kt | 16 -- .../custom/functionCallWithLambdaParam.kt | 15 -- compiler/testData/lineNumber/custom/ifThen.kt | 9 - .../testData/lineNumber/custom/ifThenElse.kt | 17 -- .../lineNumber/custom/ifThenElseFalse.kt | 10 - .../inTheEndOfLambdaArgumentOfInlineCall.kt | 19 -- .../testData/lineNumber/custom/initBlocks.kt | 46 ----- .../custom/multilineFunctionCall.kt | 10 - .../lineNumber/custom/multilineInfixCall.kt | 9 - .../noParametersArgumentCallInExpression.kt | 12 -- .../lineNumber/custom/primitiveNullChecks.kt | 7 - .../lineNumber/custom/smapInlineAsArgument.kt | 21 --- .../custom/smapInlineAsInfixArgument.kt | 19 -- .../custom/smapInlineAsInlineArgument.kt | 21 --- .../custom/smapInlineInIntrinsicArgument.kt | 17 -- .../lineNumber/custom/tryCatchExpression.kt | 15 -- .../lineNumber/custom/tryCatchFinally.kt | 19 -- .../testData/lineNumber/custom/tryFinally.kt | 15 -- compiler/testData/lineNumber/custom/when.kt | 15 -- .../testData/lineNumber/custom/whenSubject.kt | 19 -- .../kotlin/codegen/AbstractLineNumberTest.kt | 165 ----------------- .../debugInformation/AbstractSteppingTest.kt | 71 +++---- .../codegen/ir/AbstractIrLineNumberTest.kt | 77 -------- .../codegen/LineNumberTestGenerated.java | 173 ----------------- .../IrSteppingTestGenerated.java | 156 ++++++++++++++++ .../SteppingTestGenerated.java | 156 ++++++++++++++++ .../codegen/ir/IrLineNumberTestGenerated.java | 174 ------------------ .../generators/tests/GenerateCompilerTests.kt | 8 - 60 files changed, 1462 insertions(+), 1039 deletions(-) create mode 100644 compiler/testData/debug/stepping/beforeGotoToWhileStart.kt create mode 100644 compiler/testData/debug/stepping/callWithCallInArguments.kt create mode 100644 compiler/testData/debug/stepping/callWithReceiver.kt create mode 100644 compiler/testData/debug/stepping/chainCall.kt create mode 100644 compiler/testData/debug/stepping/compileTimeConstant.kt create mode 100644 compiler/testData/debug/stepping/functionCallWithDefault.kt create mode 100644 compiler/testData/debug/stepping/functionCallWithInlinedLambdaParam.kt create mode 100644 compiler/testData/debug/stepping/functionCallWithLambdaParam.kt create mode 100644 compiler/testData/debug/stepping/ifThen.kt create mode 100644 compiler/testData/debug/stepping/ifThenElse.kt create mode 100644 compiler/testData/debug/stepping/ifThenElseFalse.kt create mode 100644 compiler/testData/debug/stepping/inTheEndOfLambdaArgumentOfInlineCall.kt create mode 100644 compiler/testData/debug/stepping/initBlocks.kt create mode 100644 compiler/testData/debug/stepping/multilineFunctionCall.kt create mode 100644 compiler/testData/debug/stepping/multilineInfixCall.kt create mode 100644 compiler/testData/debug/stepping/noParametersArgumentCallInExpression.kt create mode 100644 compiler/testData/debug/stepping/primitiveNullChecks.kt create mode 100644 compiler/testData/debug/stepping/smapInlineAsArgument.kt create mode 100644 compiler/testData/debug/stepping/smapInlineAsInfixArgument.kt create mode 100644 compiler/testData/debug/stepping/smapInlineAsInlineArgument.kt create mode 100644 compiler/testData/debug/stepping/smapInlineInIntrinsicArgument.kt create mode 100644 compiler/testData/debug/stepping/tryCatchExpression.kt create mode 100644 compiler/testData/debug/stepping/tryCatchFinally.kt create mode 100644 compiler/testData/debug/stepping/tryFinally.kt create mode 100644 compiler/testData/debug/stepping/when.kt create mode 100644 compiler/testData/debug/stepping/whenSubject.kt delete mode 100644 compiler/testData/lineNumber/custom/beforeGotoToWhileStart.kt delete mode 100644 compiler/testData/lineNumber/custom/callWithCallInArguments.kt delete mode 100644 compiler/testData/lineNumber/custom/callWithReceiver.kt delete mode 100644 compiler/testData/lineNumber/custom/chainCall.kt delete mode 100644 compiler/testData/lineNumber/custom/compileTimeConstant.kt delete mode 100644 compiler/testData/lineNumber/custom/functionCallWithDefault.kt delete mode 100644 compiler/testData/lineNumber/custom/functionCallWithInlinedLambdaParam.kt delete mode 100644 compiler/testData/lineNumber/custom/functionCallWithLambdaParam.kt delete mode 100644 compiler/testData/lineNumber/custom/ifThen.kt delete mode 100644 compiler/testData/lineNumber/custom/ifThenElse.kt delete mode 100644 compiler/testData/lineNumber/custom/ifThenElseFalse.kt delete mode 100644 compiler/testData/lineNumber/custom/inTheEndOfLambdaArgumentOfInlineCall.kt delete mode 100644 compiler/testData/lineNumber/custom/initBlocks.kt delete mode 100644 compiler/testData/lineNumber/custom/multilineFunctionCall.kt delete mode 100644 compiler/testData/lineNumber/custom/multilineInfixCall.kt delete mode 100644 compiler/testData/lineNumber/custom/noParametersArgumentCallInExpression.kt delete mode 100644 compiler/testData/lineNumber/custom/primitiveNullChecks.kt delete mode 100644 compiler/testData/lineNumber/custom/smapInlineAsArgument.kt delete mode 100644 compiler/testData/lineNumber/custom/smapInlineAsInfixArgument.kt delete mode 100644 compiler/testData/lineNumber/custom/smapInlineAsInlineArgument.kt delete mode 100644 compiler/testData/lineNumber/custom/smapInlineInIntrinsicArgument.kt delete mode 100644 compiler/testData/lineNumber/custom/tryCatchExpression.kt delete mode 100644 compiler/testData/lineNumber/custom/tryCatchFinally.kt delete mode 100644 compiler/testData/lineNumber/custom/tryFinally.kt delete mode 100644 compiler/testData/lineNumber/custom/when.kt delete mode 100644 compiler/testData/lineNumber/custom/whenSubject.kt delete mode 100644 compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractLineNumberTest.kt delete mode 100644 compiler/tests-common/tests/org/jetbrains/kotlin/codegen/ir/AbstractIrLineNumberTest.kt delete mode 100644 compiler/tests/org/jetbrains/kotlin/codegen/LineNumberTestGenerated.java delete mode 100644 compiler/tests/org/jetbrains/kotlin/codegen/ir/IrLineNumberTestGenerated.java diff --git a/compiler/testData/debug/stepping/beforeGotoToWhileStart.kt b/compiler/testData/debug/stepping/beforeGotoToWhileStart.kt new file mode 100644 index 00000000000..2d303d6c79b --- /dev/null +++ b/compiler/testData/debug/stepping/beforeGotoToWhileStart.kt @@ -0,0 +1,36 @@ +// FILE: test.kt + +var current = true + +fun alternate(): Boolean { + current = !current + return current +} + +fun foo() { + while (true) { + if (alternate()) { + break + } + } +} + +fun box() { + foo() +} + +// LINENUMBERS +// test.kt:19 box +// test.kt:11 foo +// test.kt:12 foo +// test.kt:6 alternate +// test.kt:7 alternate +// test.kt:12 foo +// test.kt:11 foo +// test.kt:12 foo +// test.kt:6 alternate +// test.kt:7 alternate +// test.kt:12 foo +// test.kt:13 foo +// test.kt:16 foo +// test.kt:20 box diff --git a/compiler/testData/debug/stepping/callWithCallInArguments.kt b/compiler/testData/debug/stepping/callWithCallInArguments.kt new file mode 100644 index 00000000000..54892c5d3f8 --- /dev/null +++ b/compiler/testData/debug/stepping/callWithCallInArguments.kt @@ -0,0 +1,33 @@ +// FILE: test.kt + +class A + +fun bar(a: A) = A() + +fun box() { + val a = A() + bar( + bar( + bar(a) + ) + ) +} + +// LINENUMBERS +// test.kt:8 box +// test.kt:3 +// test.kt:8 box +// test.kt:11 box +// test.kt:5 bar +// test.kt:3 +// test.kt:5 bar +// test.kt:10 box +// test.kt:5 bar +// test.kt:3 +// test.kt:5 bar +// test.kt:9 box +// test.kt:5 bar +// test.kt:3 +// test.kt:5 bar +// test.kt:9 box +// test.kt:14 box diff --git a/compiler/testData/debug/stepping/callWithReceiver.kt b/compiler/testData/debug/stepping/callWithReceiver.kt new file mode 100644 index 00000000000..841c18607fb --- /dev/null +++ b/compiler/testData/debug/stepping/callWithReceiver.kt @@ -0,0 +1,28 @@ +// FILE: test.kt + +class A { + fun foo() = this + inline fun bar() = this +} + +fun box() { + val a = A() + a + .foo() + + a + .bar() +} + +// LINENUMBERS +// test.kt:9 box +// test.kt:3 +// test.kt:9 box +// test.kt:10 box +// test.kt:11 box +// test.kt:4 foo +// test.kt:11 box +// test.kt:13 box +// test.kt:14 box +// test.kt:5 box +// test.kt:15 box diff --git a/compiler/testData/debug/stepping/chainCall.kt b/compiler/testData/debug/stepping/chainCall.kt new file mode 100644 index 00000000000..9f2b79bfe61 --- /dev/null +++ b/compiler/testData/debug/stepping/chainCall.kt @@ -0,0 +1,30 @@ +// FILE: test.kt + +class A { + fun foo() = this + inline fun bar() = this +} + +fun box() { + val a = A() + a.foo() + .foo() + + a.bar() + .bar() +} + +// LINENUMBERS +// test.kt:9 box +// test.kt:3 +// test.kt:9 box +// test.kt:10 box +// test.kt:4 foo +// test.kt:11 box +// test.kt:4 foo +// test.kt:11 box +// test.kt:13 box +// test.kt:5 box +// test.kt:14 box +// test.kt:5 box +// test.kt:15 box \ No newline at end of file diff --git a/compiler/testData/debug/stepping/compileTimeConstant.kt b/compiler/testData/debug/stepping/compileTimeConstant.kt new file mode 100644 index 00000000000..5f8cc4377db --- /dev/null +++ b/compiler/testData/debug/stepping/compileTimeConstant.kt @@ -0,0 +1,14 @@ +// FILE: test.kt + +fun box() { + val x = + 42 +} + +// IGNORE_BACKEND: JVM_IR +// The JVM_IR backend does not hit line 4. That should be fixed. + +// LINENUMBERS +// test.kt:5 box +// test.kt:4 box +// test.kt:6 box diff --git a/compiler/testData/debug/stepping/functionCallWithDefault.kt b/compiler/testData/debug/stepping/functionCallWithDefault.kt new file mode 100644 index 00000000000..7d8a3a6ec1b --- /dev/null +++ b/compiler/testData/debug/stepping/functionCallWithDefault.kt @@ -0,0 +1,32 @@ +// FILE: test.kt + +fun box() { + foo() + bar() +} + +fun foo(i: Int = 1) { +} + +inline fun bar(i: Int = 1) { +} + +// TODO: The JVM_IR backend has line number 11 for the inlined +// default argument handling both before and after the actual +// body of bar. That is consistent with what happens with the +// $default method in the non-inlined case, but it is not what +// happens with the JVM backend. + +// FORCE_STEP_INTO +// LINENUMBERS +// test.kt:4 box +// test.kt:8 foo$default (synthetic) +// test.kt:9 foo +// test.kt:8 foo$default (synthetic) +// test.kt:5 box +// test.kt:11 box +// test.kt:12 box +// LINENUMBERS JVM_IR +// test.kt:11 box +// LINENUMBERS +// test.kt:6 box diff --git a/compiler/testData/debug/stepping/functionCallWithInlinedLambdaParam.kt b/compiler/testData/debug/stepping/functionCallWithInlinedLambdaParam.kt new file mode 100644 index 00000000000..44f76347ab6 --- /dev/null +++ b/compiler/testData/debug/stepping/functionCallWithInlinedLambdaParam.kt @@ -0,0 +1,31 @@ +// FILE: test.kt + +fun box() { + foo({ + val a = 1 + }) + + foo() { + val a = 1 + } +} + +inline fun foo(f: () -> Unit) { + val a = 1 + f() +} + +// LINENUMBERS +// test.kt:4 box +// test.kt:14 box +// test.kt:15 box +// test.kt:5 box +// test.kt:6 box +// test.kt:16 box +// test.kt:8 box +// test.kt:14 box +// test.kt:15 box +// test.kt:9 box +// test.kt:10 box +// test.kt:16 box +// test.kt:11 box diff --git a/compiler/testData/debug/stepping/functionCallWithLambdaParam.kt b/compiler/testData/debug/stepping/functionCallWithLambdaParam.kt new file mode 100644 index 00000000000..214866d377d --- /dev/null +++ b/compiler/testData/debug/stepping/functionCallWithLambdaParam.kt @@ -0,0 +1,30 @@ +// FILE: test.kt + +fun box() { + foo({ + val a = 1 + }) + + foo() { + val a = 1 + } +} + +fun foo(f: () -> Unit) { + f() +} + +// LINENUMBERS +// test.kt:4 box +// test.kt:14 foo +// test.kt:5 invoke +// test.kt:6 invoke +// test.kt:14 foo +// test.kt:15 foo +// test.kt:8 box +// test.kt:14 foo +// test.kt:9 invoke +// test.kt:10 invoke +// test.kt:14 foo +// test.kt:15 foo +// test.kt:11 box diff --git a/compiler/testData/debug/stepping/ifThen.kt b/compiler/testData/debug/stepping/ifThen.kt new file mode 100644 index 00000000000..d83c79db969 --- /dev/null +++ b/compiler/testData/debug/stepping/ifThen.kt @@ -0,0 +1,25 @@ +// FILE: test.kt + +fun foo() { + if (flag) { + return + } +} + +var flag = true + +fun box() { + foo() + flag = false + foo() +} + +// LINENUMBERS +// test.kt:12 box +// test.kt:4 foo +// test.kt:5 foo +// test.kt:13 box +// test.kt:14 box +// test.kt:4 foo +// test.kt:7 foo +// test.kt:15 box diff --git a/compiler/testData/debug/stepping/ifThenElse.kt b/compiler/testData/debug/stepping/ifThenElse.kt new file mode 100644 index 00000000000..b9e1670cef3 --- /dev/null +++ b/compiler/testData/debug/stepping/ifThenElse.kt @@ -0,0 +1,41 @@ +// FILE: test.kt + +fun foo() { + if (flag) { + "OK" + } else { + "OK" + } + + val b = if (flag) { + "OK" + } else { + "OK" + } +} + +var flag = true + +fun box() { + foo() + flag = false + foo() +} + +// LINENUMBERS +// test.kt:20 box +// test.kt:4 foo +// test.kt:5 foo +// test.kt:10 foo +// test.kt:11 foo +// test.kt:10 foo +// test.kt:15 foo +// test.kt:21 box +// test.kt:22 box +// test.kt:4 foo +// test.kt:7 foo +// test.kt:10 foo +// test.kt:13 foo +// test.kt:10 foo +// test.kt:15 foo +// test.kt:23 box diff --git a/compiler/testData/debug/stepping/ifThenElseFalse.kt b/compiler/testData/debug/stepping/ifThenElseFalse.kt new file mode 100644 index 00000000000..75496469039 --- /dev/null +++ b/compiler/testData/debug/stepping/ifThenElseFalse.kt @@ -0,0 +1,36 @@ +// FILE: test.kt + +var value = false + +fun cond() = value + +fun foo() { + if (cond()) + cond() + else + false +} + +fun box() { + foo() + value = true + foo() +} + +// LINENUMBERS +// test.kt:15 box +// test.kt:8 foo +// test.kt:5 cond +// test.kt:8 foo +// test.kt:11 foo +// test.kt:12 foo +// test.kt:16 box +// test.kt:17 box +// test.kt:8 foo +// test.kt:5 cond +// test.kt:8 foo +// test.kt:9 foo +// test.kt:5 cond +// test.kt:9 foo +// test.kt:12 foo +// test.kt:18 box diff --git a/compiler/testData/debug/stepping/inTheEndOfLambdaArgumentOfInlineCall.kt b/compiler/testData/debug/stepping/inTheEndOfLambdaArgumentOfInlineCall.kt new file mode 100644 index 00000000000..16644d61c18 --- /dev/null +++ b/compiler/testData/debug/stepping/inTheEndOfLambdaArgumentOfInlineCall.kt @@ -0,0 +1,34 @@ +// FILE: test.kt + +fun box() { + bar { + nop() + baz() + } +} + +inline fun bar(f: () -> Unit) { + nop() + f() +} + +inline fun baz() { + nop() +} + +fun nop() {} + +// LINENUMBERS +// test.kt:4 box +// test.kt:11 box +// test.kt:19 nop +// test.kt:12 box +// test.kt:5 box +// test.kt:19 nop +// test.kt:6 box +// test.kt:16 box +// test.kt:19 nop +// test.kt:17 box +// test.kt:7 box +// test.kt:13 box +// test.kt:8 box diff --git a/compiler/testData/debug/stepping/initBlocks.kt b/compiler/testData/debug/stepping/initBlocks.kt new file mode 100644 index 00000000000..b4ecbd24363 --- /dev/null +++ b/compiler/testData/debug/stepping/initBlocks.kt @@ -0,0 +1,98 @@ +// FILE: test.kt + +class Foo { + var a: String + + init { + a = x() + } +} + +class Bar { + init { + val a = 5 + } + + init { + val b = 2 + } +} + +class Boo { + init { + val a = 5 + } + + val x = x() + + init { + val b = 2 + } +} + +class Zoo { + init { val a = 5 } + + init { val b = 6 } + + init { + val c = 7 + } + + init { val d = 8 } +} + +fun x() = "" + +fun box() { + Foo() + Bar() + Boo() + Zoo() +} + +// IGNORE_BACKEND: JVM_IR +// The JVM_IR does not generate code that will break on the line +// containing the `init`, nor the exit from the `init`. It only +// contains lines for the contents of the init blocks. + +// LINENUMBERS +// test.kt:48 box +// test.kt:3 +// test.kt:6 +// test.kt:7 +// test.kt:45 x +// test.kt:7 +// test.kt:8 +// test.kt:48 box +// test.kt:49 box +// test.kt:11 +// test.kt:12 +// test.kt:13 +// test.kt:14 +// test.kt:16 +// test.kt:17 +// test.kt:18 +// test.kt:49 box +// test.kt:50 box +// test.kt:21 +// test.kt:22 +// test.kt:23 +// test.kt:24 +// test.kt:26 +// test.kt:45 x +// test.kt:26 +// test.kt:28 +// test.kt:29 +// test.kt:30 +// test.kt:50 box +// test.kt:51 box +// test.kt:33 +// test.kt:34 +// test.kt:36 +// test.kt:38 +// test.kt:39 +// test.kt:40 +// test.kt:42 +// test.kt:51 box +// test.kt:52 box diff --git a/compiler/testData/debug/stepping/multilineFunctionCall.kt b/compiler/testData/debug/stepping/multilineFunctionCall.kt new file mode 100644 index 00000000000..aa24edaeacb --- /dev/null +++ b/compiler/testData/debug/stepping/multilineFunctionCall.kt @@ -0,0 +1,16 @@ +// FILE: test.kt + +fun box() { + foo( + 1 + 1 + ) +} + +fun foo(i: Int) { +} + +// LINENUMBERS +// test.kt:5 box +// test.kt:4 box +// test.kt:10 foo +// test.kt:7 box diff --git a/compiler/testData/debug/stepping/multilineInfixCall.kt b/compiler/testData/debug/stepping/multilineInfixCall.kt new file mode 100644 index 00000000000..5082e6cc538 --- /dev/null +++ b/compiler/testData/debug/stepping/multilineInfixCall.kt @@ -0,0 +1,16 @@ +// FILE: test.kt + +fun box() { + 1 foo + 1 +} + +infix fun Int.foo(i: Int) { +} + +// LINENUMBERS +// test.kt:4 box +// test.kt:5 box +// test.kt:4 box +// test.kt:9 foo +// test.kt:6 box diff --git a/compiler/testData/debug/stepping/noParametersArgumentCallInExpression.kt b/compiler/testData/debug/stepping/noParametersArgumentCallInExpression.kt new file mode 100644 index 00000000000..eae20a8bb9f --- /dev/null +++ b/compiler/testData/debug/stepping/noParametersArgumentCallInExpression.kt @@ -0,0 +1,20 @@ +// FILE: test.kt + +fun box() { + lookAtMe { + 42 + } +} + +inline fun lookAtMe(f: () -> Int) { + val a = 21 + a + f() +} + +// LINENUMBERS +// test.kt:4 box +// test.kt:10 box +// test.kt:11 box +// test.kt:5 box +// test.kt:12 box +// test.kt:7 box diff --git a/compiler/testData/debug/stepping/primitiveNullChecks.kt b/compiler/testData/debug/stepping/primitiveNullChecks.kt new file mode 100644 index 00000000000..e7f7c8ab4e7 --- /dev/null +++ b/compiler/testData/debug/stepping/primitiveNullChecks.kt @@ -0,0 +1,12 @@ +// FILE: test.kt + +fun box(): String { + 42!! + 42.toLong()!! + return "OK"!! +} + +// LINENUMBERS +// test.kt:4 box +// test.kt:5 box +// test.kt:6 box \ No newline at end of file diff --git a/compiler/testData/debug/stepping/smapInlineAsArgument.kt b/compiler/testData/debug/stepping/smapInlineAsArgument.kt new file mode 100644 index 00000000000..7be09f2b2ce --- /dev/null +++ b/compiler/testData/debug/stepping/smapInlineAsArgument.kt @@ -0,0 +1,38 @@ +// FILE: test.kt + +fun box(){ + checkEquals(test(), + fail()) + + checkEquals(fail(), + test()) +} + +public fun checkEquals(p1: String, p2: String) { + "check" +} + +inline fun test() : String { + return "123" +} + +fun fail() : String { + return "fail" +} + +// LINENUMBERS +// test.kt:4 box +// test.kt:16 box +// test.kt:5 box +// test.kt:20 fail +// test.kt:4 box +// test.kt:12 checkEquals +// test.kt:13 checkEquals +// test.kt:7 box +// test.kt:20 fail +// test.kt:8 box +// test.kt:16 box +// test.kt:7 box +// test.kt:12 checkEquals +// test.kt:13 checkEquals +// test.kt:9 box \ No newline at end of file diff --git a/compiler/testData/debug/stepping/smapInlineAsInfixArgument.kt b/compiler/testData/debug/stepping/smapInlineAsInfixArgument.kt new file mode 100644 index 00000000000..14df7384dc0 --- /dev/null +++ b/compiler/testData/debug/stepping/smapInlineAsInfixArgument.kt @@ -0,0 +1,36 @@ +// FILE: test.kt + +infix fun String.execute(p: String) = this + p + +fun box(){ + test() execute + fail() + + fail() execute + test() +} + +inline fun test() : String { + return "123" +} + +fun fail() : String { + return "fail" +} + +// LINENUMBERS +// test.kt:6 box +// test.kt:14 box +// test.kt:7 box +// test.kt:18 fail +// test.kt:6 box +// test.kt:3 execute +// test.kt:6 box +// test.kt:9 box +// test.kt:18 fail +// test.kt:10 box +// test.kt:14 box +// test.kt:9 box +// test.kt:3 execute +// test.kt:9 box +// test.kt:11 box diff --git a/compiler/testData/debug/stepping/smapInlineAsInlineArgument.kt b/compiler/testData/debug/stepping/smapInlineAsInlineArgument.kt new file mode 100644 index 00000000000..07da14e9b4b --- /dev/null +++ b/compiler/testData/debug/stepping/smapInlineAsInlineArgument.kt @@ -0,0 +1,38 @@ +// FILE: test.kt + +fun box(){ + test(test("1", "2"), + fail()) + + test(fail(), + test("1", "2")) +} + +public fun checkEquals(p1: String, p2: String) { + "check" +} + +inline fun test(p: String, s: String) : String { + return "123" +} + +fun fail() : String { + return "fail" +} + +// LINENUMBERS +// test.kt:4 box +// test.kt:16 box +// test.kt:5 box +// test.kt:20 fail +// test.kt:5 box +// test.kt:4 box +// test.kt:16 box +// test.kt:7 box +// test.kt:20 fail +// test.kt:7 box +// test.kt:8 box +// test.kt:16 box +// test.kt:7 box +// test.kt:16 box +// test.kt:9 box diff --git a/compiler/testData/debug/stepping/smapInlineInIntrinsicArgument.kt b/compiler/testData/debug/stepping/smapInlineInIntrinsicArgument.kt new file mode 100644 index 00000000000..b63084b4638 --- /dev/null +++ b/compiler/testData/debug/stepping/smapInlineInIntrinsicArgument.kt @@ -0,0 +1,37 @@ +// FILE: test.kt + +fun box(){ + test() + + fail() + + fail() + + test() +} + +inline fun test() : String { + return "123" +} + +fun fail() : String { + return "fail" +} + +// IGNORE_BACKEND: JVM + +// The JVM backend does not go back to line 4 and 7 for the +// addition. Instead it treats the addition of the evaluated +// arguments as being on line 5 and 8. That seems incorrect +// and the JVM_IR stepping is more correct. + +// LINENUMBERS +// test.kt:4 box +// test.kt:12 box +// test.kt:5 box +// test.kt:16 fail +// test.kt:4 box +// test.kt:7 box +// test.kt:16 fail +// test.kt:8 box +// test.kt:12 box +// test.kt:7 box +// test.kt:9 box \ No newline at end of file diff --git a/compiler/testData/debug/stepping/tryCatchExpression.kt b/compiler/testData/debug/stepping/tryCatchExpression.kt new file mode 100644 index 00000000000..5efc1eacbd5 --- /dev/null +++ b/compiler/testData/debug/stepping/tryCatchExpression.kt @@ -0,0 +1,73 @@ +// FILE: test.kt + +fun foo() { + try { + mightThrow() + } catch (e: Throwable) { + return + } + + val t = try { + mightThrow2() + } catch (e: Throwable) { + return + } +} + +var throw1 = false +var throw2 = false + +fun mightThrow() { + if (throw1) throw Exception() +} + +fun mightThrow2() { + if (throw2) throw Exception() +} + +fun box() { + foo() + throw2 = true + foo() + throw1 = true + foo() +} + +// IGNORE_BACKEND: JVM_IR +// The JVM_IR backend will stop on line 13 even when mightThrow2 +// does not throw! + +// LINENUMBERS +// test.kt:29 box +// test.kt:4 foo +// test.kt:5 foo +// test.kt:21 mightThrow +// test.kt:22 mightThrow +// test.kt:5 foo +// test.kt:10 foo +// test.kt:11 foo +// test.kt:25 mightThrow2 +// test.kt:26 mightThrow2 +// test.kt:11 foo +// test.kt:10 foo +// test.kt:15 foo +// test.kt:30 box +// test.kt:31 box +// test.kt:4 foo +// test.kt:5 foo +// test.kt:21 mightThrow +// test.kt:22 mightThrow +// test.kt:5 foo +// test.kt:10 foo +// test.kt:11 foo +// test.kt:25 mightThrow2 +// test.kt:12 foo +// test.kt:13 foo +// test.kt:32 box +// test.kt:33 box +// test.kt:4 foo +// test.kt:5 foo +// test.kt:21 mightThrow +// test.kt:6 foo +// test.kt:7 foo +// test.kt:34 box diff --git a/compiler/testData/debug/stepping/tryCatchFinally.kt b/compiler/testData/debug/stepping/tryCatchFinally.kt new file mode 100644 index 00000000000..f1705d17ec1 --- /dev/null +++ b/compiler/testData/debug/stepping/tryCatchFinally.kt @@ -0,0 +1,96 @@ +// FILE: test.kt + +fun foo() { + try { + mightThrow() + } catch (e: Throwable) { + "OK" + } finally { + "FINALLY" + } + + val t = try { + mightThrow2() + } catch (e: Throwable) { + "OK2" + } finally { + "FINALLY2" + } +} + +var throw1 = false +var throw2 = false + +fun mightThrow() { + if (throw1) throw Exception() +} + +fun mightThrow2() { + if (throw2) throw Exception() +} + +fun box() { + foo() + throw2 = true + foo() + throw1 = true + foo() +} + +// IGNORE_BACKEND: JVM_IR +// The JVM_IR backend goes back to line 17 after line 18. It has the +// sequence 17, 18, 17 which doesn't make sense. + +// LINENUMBERS +// test.kt:33 box +// test.kt:4 foo +// test.kt:5 foo +// test.kt:25 mightThrow +// test.kt:26 mightThrow +// test.kt:9 foo +// test.kt:10 foo +// test.kt:12 foo +// test.kt:13 foo +// test.kt:29 mightThrow2 +// test.kt:30 mightThrow2 +// test.kt:13 foo +// test.kt:17 foo +// test.kt:18 foo +// test.kt:12 foo +// test.kt:19 foo +// test.kt:34 box +// test.kt:35 box +// test.kt:4 foo +// test.kt:5 foo +// test.kt:25 mightThrow +// test.kt:26 mightThrow +// test.kt:9 foo +// test.kt:10 foo +// test.kt:12 foo +// test.kt:13 foo +// test.kt:29 mightThrow2 +// test.kt:14 foo +// test.kt:15 foo +// test.kt:17 foo +// test.kt:18 foo +// test.kt:12 foo +// test.kt:19 foo +// test.kt:36 box +// test.kt:37 box +// test.kt:4 foo +// test.kt:5 foo +// test.kt:25 mightThrow +// test.kt:6 foo +// test.kt:7 foo +// test.kt:9 foo +// test.kt:10 foo +// test.kt:12 foo +// test.kt:13 foo +// test.kt:29 mightThrow2 +// test.kt:14 foo +// test.kt:15 foo +// test.kt:17 foo +// test.kt:18 foo +// test.kt:12 foo +// test.kt:19 foo +// test.kt:38 box diff --git a/compiler/testData/debug/stepping/tryFinally.kt b/compiler/testData/debug/stepping/tryFinally.kt new file mode 100644 index 00000000000..82942faa00f --- /dev/null +++ b/compiler/testData/debug/stepping/tryFinally.kt @@ -0,0 +1,70 @@ +// FILE: test.kt + +fun foo() { + try { + mightThrow() + } finally { + "FINALLY" + } + + val t = try { + mightThrow2() + } finally { + "FINALLY2" + } +} + +var throw1 = false +var throw2 = false + +fun mightThrow() { + if (throw1) throw Exception() +} + +fun mightThrow2() { + if (throw2) throw Exception() +} + +fun box() { + foo() + throw2 = true + foo() + // Never gets here. + throw1 = true + foo() +} + +// IGNORE_BACKEND: JVM_IR +// The JVM_IR backend goes back to line 13 after line 14. It has the +// sequence 13, 14, 13 which doesn't make sense. + +// LINENUMBERS +// test.kt:29 box +// test.kt:4 foo +// test.kt:5 foo +// test.kt:21 mightThrow +// test.kt:22 mightThrow +// test.kt:7 foo +// test.kt:8 foo +// test.kt:10 foo +// test.kt:11 foo +// test.kt:25 mightThrow2 +// test.kt:26 mightThrow2 +// test.kt:11 foo +// test.kt:13 foo +// test.kt:14 foo +// test.kt:10 foo +// test.kt:15 foo +// test.kt:30 box +// test.kt:31 box +// test.kt:4 foo +// test.kt:5 foo +// test.kt:21 mightThrow +// test.kt:22 mightThrow +// test.kt:7 foo +// test.kt:8 foo +// test.kt:10 foo +// test.kt:11 foo +// test.kt:25 mightThrow2 +// test.kt:14 foo +// test.kt:13 foo diff --git a/compiler/testData/debug/stepping/when.kt b/compiler/testData/debug/stepping/when.kt new file mode 100644 index 00000000000..16eb234d4d5 --- /dev/null +++ b/compiler/testData/debug/stepping/when.kt @@ -0,0 +1,98 @@ +// FILE: test.kt + +fun foo(x: Int) { + when { + x == 21 -> foo(42) + x == 42 -> foo(63) + else -> 1 + } + + val t = when { + x == 21 -> foo(42) + x == 42 -> foo(63) + else -> 2 + } +} + +fun box() { + foo(21) +} + +// IGNORE_BACKEND: JVM_IR + +// The JVM_IR backend has line number 8 when leaving the first +// when. Also, the stepping is different, probably because the when +// is compiled to a switch which it isn't with JVM? The stepping +// behavior is likely OK, but should be double checked. + +// LINENUMBERS +// test.kt:18 box +// test.kt:4 foo +// test.kt:5 foo +// test.kt:4 foo +// test.kt:5 foo +// test.kt:6 foo +// test.kt:4 foo +// test.kt:5 foo +// test.kt:6 foo +// test.kt:7 foo +// test.kt:10 foo +// test.kt:11 foo +// test.kt:12 foo +// test.kt:13 foo +// test.kt:10 foo +// test.kt:15 foo +// test.kt:6 foo +// test.kt:10 foo +// test.kt:11 foo +// test.kt:12 foo +// test.kt:4 foo +// test.kt:5 foo +// test.kt:6 foo +// test.kt:7 foo +// test.kt:10 foo +// test.kt:11 foo +// test.kt:12 foo +// test.kt:13 foo +// test.kt:10 foo +// test.kt:15 foo +// test.kt:12 foo +// test.kt:10 foo +// test.kt:15 foo +// test.kt:5 foo +// test.kt:10 foo +// test.kt:11 foo +// test.kt:4 foo +// test.kt:5 foo +// test.kt:6 foo +// test.kt:4 foo +// test.kt:5 foo +// test.kt:6 foo +// test.kt:7 foo +// test.kt:10 foo +// test.kt:11 foo +// test.kt:12 foo +// test.kt:13 foo +// test.kt:10 foo +// test.kt:15 foo +// test.kt:6 foo +// test.kt:10 foo +// test.kt:11 foo +// test.kt:12 foo +// test.kt:4 foo +// test.kt:5 foo +// test.kt:6 foo +// test.kt:7 foo +// test.kt:10 foo +// test.kt:11 foo +// test.kt:12 foo +// test.kt:13 foo +// test.kt:10 foo +// test.kt:15 foo +// test.kt:12 foo +// test.kt:10 foo +// test.kt:15 foo +// test.kt:11 foo +// test.kt:10 foo +// test.kt:15 foo +// test.kt:19 box diff --git a/compiler/testData/debug/stepping/whenSubject.kt b/compiler/testData/debug/stepping/whenSubject.kt new file mode 100644 index 00000000000..10d08c8f366 --- /dev/null +++ b/compiler/testData/debug/stepping/whenSubject.kt @@ -0,0 +1,94 @@ +// FILE: test.kt + +fun foo(x: Int) { + when (x) { + 21 -> foo(42) + 42 -> foo(63) + else -> 1 + } + + val t = when (x) { + 21 -> foo(42) + 42 -> foo(63) + else -> 1 + } +} + +fun box() { + foo(21) +} + +// JVM_IR stops on line 8 when exiting the first when. + +// LINENUMBERS +// test.kt:18 box +// test.kt:4 foo +// test.kt:5 foo +// test.kt:4 foo +// test.kt:6 foo +// test.kt:4 foo +// test.kt:7 foo +// LINENUMBERS JVM_IR +// test.kt:8 foo +// LINENUMBERS +// test.kt:10 foo +// test.kt:13 foo +// test.kt:10 foo +// test.kt:15 foo +// test.kt:6 foo +// LINENUMBERS JVM_IR +// test.kt:8 foo +// LINENUMBERS +// test.kt:10 foo +// test.kt:12 foo +// test.kt:4 foo +// test.kt:7 foo +// LINENUMBERS JVM_IR +// test.kt:8 foo +// LINENUMBERS +// test.kt:10 foo +// test.kt:13 foo +// test.kt:10 foo +// test.kt:15 foo +// test.kt:12 foo +// test.kt:10 foo +// test.kt:15 foo +// test.kt:5 foo +// LINENUMBERS JVM_IR +// test.kt:8 foo +// LINENUMBERS +// test.kt:10 foo +// test.kt:11 foo +// test.kt:4 foo +// test.kt:6 foo +// test.kt:4 foo +// test.kt:7 foo +// LINENUMBERS JVM_IR +// test.kt:8 foo +// LINENUMBERS +// test.kt:10 foo +// test.kt:13 foo +// test.kt:10 foo +// test.kt:15 foo +// test.kt:6 foo +// LINENUMBERS JVM_IR +// test.kt:8 foo +// LINENUMBERS +// test.kt:10 foo +// test.kt:12 foo +// test.kt:4 foo +// test.kt:7 foo +// LINENUMBERS JVM_IR +// test.kt:8 foo +// LINENUMBERS +// test.kt:10 foo +// test.kt:13 foo +// test.kt:10 foo +// test.kt:15 foo +// test.kt:12 foo +// test.kt:10 foo +// test.kt:15 foo +// test.kt:11 foo +// test.kt:10 foo +// test.kt:15 foo +// test.kt:19 box \ No newline at end of file diff --git a/compiler/testData/lineNumber/custom/beforeGotoToWhileStart.kt b/compiler/testData/lineNumber/custom/beforeGotoToWhileStart.kt deleted file mode 100644 index 0cb7ee0dfd4..00000000000 --- a/compiler/testData/lineNumber/custom/beforeGotoToWhileStart.kt +++ /dev/null @@ -1,13 +0,0 @@ -fun foo() { - while (true) { - if (testSome()) { - break - } - } -} - -fun testSome(): Boolean { - return false -} - -// 2 3 4 2 7 10 \ No newline at end of file diff --git a/compiler/testData/lineNumber/custom/callWithCallInArguments.kt b/compiler/testData/lineNumber/custom/callWithCallInArguments.kt deleted file mode 100644 index 49258150d32..00000000000 --- a/compiler/testData/lineNumber/custom/callWithCallInArguments.kt +++ /dev/null @@ -1,17 +0,0 @@ -class A { - fun foo(a: A) = a -} - -fun bar(a: A) = A() - -fun foo() { - val a = A() - bar( - bar( - bar(a) - ) - ) - -} - -// 2 1 5 8 9 +10 +11 10 9 15 \ No newline at end of file diff --git a/compiler/testData/lineNumber/custom/callWithReceiver.kt b/compiler/testData/lineNumber/custom/callWithReceiver.kt deleted file mode 100644 index 69c92dad789..00000000000 --- a/compiler/testData/lineNumber/custom/callWithReceiver.kt +++ /dev/null @@ -1,15 +0,0 @@ -class A { - fun foo() = this - inline fun bar() = this -} - -fun foo() { - val a = A() - a - .foo() - - a - .bar() -} - -// 2 3 1 7 8 +9 +8 9 11 +12 +11 12 16 13 \ No newline at end of file diff --git a/compiler/testData/lineNumber/custom/chainCall.kt b/compiler/testData/lineNumber/custom/chainCall.kt deleted file mode 100644 index 0046cec9a9f..00000000000 --- a/compiler/testData/lineNumber/custom/chainCall.kt +++ /dev/null @@ -1,15 +0,0 @@ -class A { - fun foo() = this - inline fun bar() = this -} - -fun foo() { - val a = A() - a.foo() - .foo() - - a.bar() - .bar() -} - -// 2 3 1 7 8 +9 +8 9 11 +12 +11 16 12 17 13 \ No newline at end of file diff --git a/compiler/testData/lineNumber/custom/compileTimeConstant.kt b/compiler/testData/lineNumber/custom/compileTimeConstant.kt deleted file mode 100644 index 4146efee5fd..00000000000 --- a/compiler/testData/lineNumber/custom/compileTimeConstant.kt +++ /dev/null @@ -1,6 +0,0 @@ -fun foo() { - val x = - 42 -} - -// 2 +3 2 4 \ No newline at end of file diff --git a/compiler/testData/lineNumber/custom/functionCallWithDefault.kt b/compiler/testData/lineNumber/custom/functionCallWithDefault.kt deleted file mode 100644 index 8cdcb1108f8..00000000000 --- a/compiler/testData/lineNumber/custom/functionCallWithDefault.kt +++ /dev/null @@ -1,12 +0,0 @@ -fun test() { - foo() - bar() -} - -fun foo(i: Int = 1) { -} - -inline fun bar(i: Int = 1) { -} - -// 2 3 13 14 4 7 6 10 9 10 \ No newline at end of file diff --git a/compiler/testData/lineNumber/custom/functionCallWithInlinedLambdaParam.kt b/compiler/testData/lineNumber/custom/functionCallWithInlinedLambdaParam.kt deleted file mode 100644 index 2f348a153a5..00000000000 --- a/compiler/testData/lineNumber/custom/functionCallWithInlinedLambdaParam.kt +++ /dev/null @@ -1,16 +0,0 @@ -fun foo() { - foo({ - val a = 1 - }) - - foo() { - val a = 1 - } -} - -inline fun foo(f: () -> Unit) { - val a = 1 - f() -} - -// 2 17 18 3 4 19 6 20 21 7 8 22 9 12 13 14 \ No newline at end of file diff --git a/compiler/testData/lineNumber/custom/functionCallWithLambdaParam.kt b/compiler/testData/lineNumber/custom/functionCallWithLambdaParam.kt deleted file mode 100644 index 392aa085d4c..00000000000 --- a/compiler/testData/lineNumber/custom/functionCallWithLambdaParam.kt +++ /dev/null @@ -1,15 +0,0 @@ -fun foo() { - foo({ - val a = 1 - }) - - foo() { - val a = 1 - } -} - -fun foo(f: () -> Unit) { - f() -} - -// 2 6 9 12 13 3 4 7 8 diff --git a/compiler/testData/lineNumber/custom/ifThen.kt b/compiler/testData/lineNumber/custom/ifThen.kt deleted file mode 100644 index 887ddee99d6..00000000000 --- a/compiler/testData/lineNumber/custom/ifThen.kt +++ /dev/null @@ -1,9 +0,0 @@ -fun foo() { - if (flag) { - return - } -} - -val flag = true - -// 2 3 5 7 7 \ No newline at end of file diff --git a/compiler/testData/lineNumber/custom/ifThenElse.kt b/compiler/testData/lineNumber/custom/ifThenElse.kt deleted file mode 100644 index 17d8515ccbd..00000000000 --- a/compiler/testData/lineNumber/custom/ifThenElse.kt +++ /dev/null @@ -1,17 +0,0 @@ -fun foo() { - if (flag) { - System.out?.println() - } else { - System.out?.println() - } - - val b = if (flag) { - System.out?.println() - } else { - System.out?.println() - } -} - -val flag = true - -// 2 3 5 6 +8 9 11 8 13 15 15 \ No newline at end of file diff --git a/compiler/testData/lineNumber/custom/ifThenElseFalse.kt b/compiler/testData/lineNumber/custom/ifThenElseFalse.kt deleted file mode 100644 index 57ece85a601..00000000000 --- a/compiler/testData/lineNumber/custom/ifThenElseFalse.kt +++ /dev/null @@ -1,10 +0,0 @@ -fun cond() = false - -fun foo() { - if (cond()) - cond() - else - false -} - -// 1 4 5 7 8 \ No newline at end of file diff --git a/compiler/testData/lineNumber/custom/inTheEndOfLambdaArgumentOfInlineCall.kt b/compiler/testData/lineNumber/custom/inTheEndOfLambdaArgumentOfInlineCall.kt deleted file mode 100644 index b95dc8e04db..00000000000 --- a/compiler/testData/lineNumber/custom/inTheEndOfLambdaArgumentOfInlineCall.kt +++ /dev/null @@ -1,19 +0,0 @@ -fun foo() { - bar { - nop() - baz() - } -} - -inline fun bar(f: () -> Unit) { - nop() - f() -} - -inline fun baz() { - nop() -} - -fun nop() {} - -// 2 20 21 3 4 22 23 5 24 6 9 10 11 14 15 17 \ No newline at end of file diff --git a/compiler/testData/lineNumber/custom/initBlocks.kt b/compiler/testData/lineNumber/custom/initBlocks.kt deleted file mode 100644 index 09b0cecb0e5..00000000000 --- a/compiler/testData/lineNumber/custom/initBlocks.kt +++ /dev/null @@ -1,46 +0,0 @@ -class Foo { - var a: String - - init { - a = x() - } -} - -class Bar { - init { - val a = 5 - } - - init { - val b = 2 - } -} - -class Boo { - init { - val a = 5 - } - - val x = x() - - init { - val b = 2 - } -} - -class Zoo { - init { val a = 5 } - - init { val b = 6 } - - init { - val c = 7 - } - - init { val d = 8 } -} - -fun x() = "" - -// IGNORE_BACKEND: JVM_IR -// 2 2 1 4 5 6 9 10 11 12 14 15 16 24 19 20 21 22 24 26 27 28 31 32 34 36 37 38 40 43 \ No newline at end of file diff --git a/compiler/testData/lineNumber/custom/multilineFunctionCall.kt b/compiler/testData/lineNumber/custom/multilineFunctionCall.kt deleted file mode 100644 index b3e9bd9eb1e..00000000000 --- a/compiler/testData/lineNumber/custom/multilineFunctionCall.kt +++ /dev/null @@ -1,10 +0,0 @@ -fun foo() { - foo( - 1 + 1 - ) -} - -fun foo(i: Int) { -} - -// 2 +3 2 5 8 \ No newline at end of file diff --git a/compiler/testData/lineNumber/custom/multilineInfixCall.kt b/compiler/testData/lineNumber/custom/multilineInfixCall.kt deleted file mode 100644 index b4a8f145ecd..00000000000 --- a/compiler/testData/lineNumber/custom/multilineInfixCall.kt +++ /dev/null @@ -1,9 +0,0 @@ -fun foo() { - 1 foo - 1 -} - -infix fun Int.foo(i: Int) { -} - -// 2 3 2 4 7 \ No newline at end of file diff --git a/compiler/testData/lineNumber/custom/noParametersArgumentCallInExpression.kt b/compiler/testData/lineNumber/custom/noParametersArgumentCallInExpression.kt deleted file mode 100644 index 46a34bcae2d..00000000000 --- a/compiler/testData/lineNumber/custom/noParametersArgumentCallInExpression.kt +++ /dev/null @@ -1,12 +0,0 @@ -fun box() { - lookAtMe { - 42 - } -} - -inline fun lookAtMe(f: () -> Int) { - val a = 21 - a + f() -} - -// 2 13 14 3 15 5 8 9 10 \ No newline at end of file diff --git a/compiler/testData/lineNumber/custom/primitiveNullChecks.kt b/compiler/testData/lineNumber/custom/primitiveNullChecks.kt deleted file mode 100644 index a9073cf94e9..00000000000 --- a/compiler/testData/lineNumber/custom/primitiveNullChecks.kt +++ /dev/null @@ -1,7 +0,0 @@ -fun box(): String { - 42!! - 42.toLong()!! - return "OK"!! -} - -// 2 3 4 \ No newline at end of file diff --git a/compiler/testData/lineNumber/custom/smapInlineAsArgument.kt b/compiler/testData/lineNumber/custom/smapInlineAsArgument.kt deleted file mode 100644 index caadb200911..00000000000 --- a/compiler/testData/lineNumber/custom/smapInlineAsArgument.kt +++ /dev/null @@ -1,21 +0,0 @@ -fun box(){ - checkEquals(test(), - fail()) - - checkEquals(fail(), - test()) -} - -public fun checkEquals(p1: String, p2: String) { - throw AssertionError("fail") -} - -inline fun test() : String { - return "123" -} - -fun fail() : String { - throw AssertionError("fail") -} - -// 2 22 3 2 5 6 23 5 7 10 14 18 \ No newline at end of file diff --git a/compiler/testData/lineNumber/custom/smapInlineAsInfixArgument.kt b/compiler/testData/lineNumber/custom/smapInlineAsInfixArgument.kt deleted file mode 100644 index 3a07f084958..00000000000 --- a/compiler/testData/lineNumber/custom/smapInlineAsInfixArgument.kt +++ /dev/null @@ -1,19 +0,0 @@ -infix fun String.execute(p: String) = this + p - -fun box(){ - test() execute - fail() - - fail() execute - test() -} - -inline fun test() : String { - return "123" -} - -fun fail() : String { - throw AssertionError("fail") -} - -// 1 4 20 5 4 7 8 21 7 9 12 16 \ No newline at end of file diff --git a/compiler/testData/lineNumber/custom/smapInlineAsInlineArgument.kt b/compiler/testData/lineNumber/custom/smapInlineAsInlineArgument.kt deleted file mode 100644 index f69932bd9aa..00000000000 --- a/compiler/testData/lineNumber/custom/smapInlineAsInlineArgument.kt +++ /dev/null @@ -1,21 +0,0 @@ -fun box(){ - test(test("1", "2"), - fail()) - - test(fail(), - test("1", "2")) -} - -public fun checkEquals(p1: String, p2: String) { - throw AssertionError("fail") -} - -inline fun test(p: String, s: String) : String { - return "123" -} - -fun fail() : String { - throw AssertionError("fail") -} - -// 2 22 3 2 22 5 6 23 5 24 7 10 14 18 \ No newline at end of file diff --git a/compiler/testData/lineNumber/custom/smapInlineInIntrinsicArgument.kt b/compiler/testData/lineNumber/custom/smapInlineInIntrinsicArgument.kt deleted file mode 100644 index f4caac240bb..00000000000 --- a/compiler/testData/lineNumber/custom/smapInlineInIntrinsicArgument.kt +++ /dev/null @@ -1,17 +0,0 @@ -fun box(){ - test() + - fail() - - fail() + - test() -} - -inline fun test() : String { - return "123" -} - -fun fail() : String { - throw AssertionError("fail") -} - -// 2 18 3 5 6 19 7 10 14 \ No newline at end of file diff --git a/compiler/testData/lineNumber/custom/tryCatchExpression.kt b/compiler/testData/lineNumber/custom/tryCatchExpression.kt deleted file mode 100644 index c2955009952..00000000000 --- a/compiler/testData/lineNumber/custom/tryCatchExpression.kt +++ /dev/null @@ -1,15 +0,0 @@ -fun foo() { - try { - System.out?.println() - } catch (e: Throwable) { - return - } - - val t = try { - System.out?.println() - } catch (e: Throwable) { - return - } -} - -// 2 3 4 5 6 +8 9 10 11 8 13 \ No newline at end of file diff --git a/compiler/testData/lineNumber/custom/tryCatchFinally.kt b/compiler/testData/lineNumber/custom/tryCatchFinally.kt deleted file mode 100644 index 05218c3289d..00000000000 --- a/compiler/testData/lineNumber/custom/tryCatchFinally.kt +++ /dev/null @@ -1,19 +0,0 @@ -fun foo() { - try { - System.out?.println() - } catch (e: Throwable) { - System.out?.println() - } finally { - System.out?.println() - } - - val t = try { - System.out?.println() - } catch (e: Throwable) { - System.out?.println() - } finally { - System.out?.println() - } -} - -// 2 3 7 8 4 5 7 8 7 8 +10 11 15 16 12 13 15 16 15 10 17 \ No newline at end of file diff --git a/compiler/testData/lineNumber/custom/tryFinally.kt b/compiler/testData/lineNumber/custom/tryFinally.kt deleted file mode 100644 index 51e03b80539..00000000000 --- a/compiler/testData/lineNumber/custom/tryFinally.kt +++ /dev/null @@ -1,15 +0,0 @@ -fun foo() { - try { - System.out?.println() - } finally { - System.out?.println() - } - - val t = try { - System.out?.println() - } finally { - System.out?.println() - } -} - -// 2 3 5 6 5 6 +8 9 11 12 11 8 13 \ No newline at end of file diff --git a/compiler/testData/lineNumber/custom/when.kt b/compiler/testData/lineNumber/custom/when.kt deleted file mode 100644 index 2f05713e84b..00000000000 --- a/compiler/testData/lineNumber/custom/when.kt +++ /dev/null @@ -1,15 +0,0 @@ -fun foo(x: Int) { - when { - x == 21 -> foo(x) - x == 42 -> foo(x) - else -> foo(x) - } - - val t = when { - x == 21 -> foo(x) - x == 42 -> foo(x) - else -> foo(x) - } -} - -// 2 3 4 5 6 +8 9 10 11 8 13 \ No newline at end of file diff --git a/compiler/testData/lineNumber/custom/whenSubject.kt b/compiler/testData/lineNumber/custom/whenSubject.kt deleted file mode 100644 index 93a63c312b4..00000000000 --- a/compiler/testData/lineNumber/custom/whenSubject.kt +++ /dev/null @@ -1,19 +0,0 @@ -fun foo(x: Int) { - when (x) { - 21 -> foo(x) - 42 -> foo(x) - else -> foo(x) - } - - val t = when (x) { - 21 -> foo(x) - 42 -> foo(x) - else -> foo(x) - } -} - -// JVM_IR also generates a LINENUMBER 12, which seems consistent with the fact that -// there is a LINENUMBER 6, but still fails the test. -// IGNORE_BACKEND: JVM_IR - -// 2 3 4 5 6 +8 9 10 11 8 13 \ No newline at end of file diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractLineNumberTest.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractLineNumberTest.kt deleted file mode 100644 index 4efbe3dd453..00000000000 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractLineNumberTest.kt +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.codegen - -import com.intellij.openapi.util.text.StringUtil -import org.jetbrains.kotlin.psi.KtFile -import org.jetbrains.kotlin.test.KotlinTestUtils -import org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase -import org.jetbrains.org.objectweb.asm.* -import java.io.File -import java.util.* -import java.util.regex.Pattern -import kotlin.collections.ArrayList - -abstract class AbstractLineNumberTest : CodegenTestCase() { - - override fun doMultiFileTest(wholeFile: File, files: List) { - val isCustomTest = wholeFile.parentFile.name.equals("custom", ignoreCase = true) - compile(if (!isCustomTest) files + createLineNumberDeclaration() else files) - - val psiFile = myFiles.psiFiles.single { file -> file.name == wholeFile.name } - - try { - if (isCustomTest) { - compareCustom(psiFile, wholeFile) - } else { - val expectedLineNumbers = extractSelectedLineNumbersFromSource(psiFile) - val actualLineNumbers = extractActualLineNumbersFromBytecode(classFileFactory, true) - assertFalse("Missed 'lineNumbers' calls in test data", expectedLineNumbers.isEmpty()) - KtUsefulTestCase.assertSameElements(actualLineNumbers, expectedLineNumbers) - } - } catch (e: Throwable) { - printReport(wholeFile) - throw e - } - } - - protected open fun compareCustom(psiFile: KtFile, wholeFile: File) { - val actualLineNumbers = extractActualLineNumbersFromBytecode(classFileFactory, false) - val text = psiFile.text - val newFileText = text.substring(0 until Regex("// \\d+").find(text)!!.range.first) + - getActualLineNumbersAsString(actualLineNumbers) - KotlinTestUtils.assertEqualsToFile(wholeFile, newFileText) - } - - protected fun extractActualLineNumbersFromBytecode(factory: ClassFileFactory, testFunInvoke: Boolean) = - factory.getClassFiles().flatMap { outputFile -> - val cr = ClassReader(outputFile.asByteArray()) - if (testFunInvoke) readTestFunLineNumbers(cr) else readAllLineNumbers(cr) - } - - protected open fun readTestFunLineNumbers(cr: ClassReader): List { - val labels = arrayListOf