[IR] Correct line number on suspend function with implicit unit return

This commit is contained in:
Kristoffer Andersen
2020-11-03 20:13:55 +01:00
committed by max-kammerer
parent c2fec38384
commit 297c33b452
5 changed files with 69 additions and 1 deletions
@@ -39,7 +39,7 @@ private class TailCallOptimizationLowering(private val context: JvmBackendContex
override fun visitCall(expression: IrCall, data: TailCallOptimizationData?): IrExpression {
val transformed = super.visitCall(expression, data) as IrExpression
return if (data == null || expression !in data.tailCalls) transformed else IrReturnImpl(
expression.startOffset, expression.endOffset, context.irBuiltIns.nothingType, data.function.symbol,
data.function.endOffset, data.function.endOffset, context.irBuiltIns.nothingType, data.function.symbol,
if (data.returnsUnit) transformed.coerceToUnit() else transformed
)
}
@@ -0,0 +1,19 @@
// WITH_COROUTINES
// FILE: test.kt
suspend fun foo(block: Long.() -> String): String {
return 1L.block()
}
suspend fun box() {
foo {
"OK"
}
}
// LINENUMBERS
// test.kt:8 box
// test.kt:4 foo
// test.kt:9 invoke
// test.kt:4 foo
// test.kt:8 box
// test.kt:11 box
@@ -0,0 +1,25 @@
// WITH_COROUTINES
// FILE: test.kt
suspend fun foo(block: suspend Long.() -> String): String {
return 1L.block()
}
suspend fun box() {
foo {
"OK"
}
}
// LINENUMBERS
// test.kt:8 box
// test.kt:4 foo
// CoroutineUtil.kt:28 getContext
// test.kt:-1 <init>
// test.kt:-1 create
// test.kt:-1 invoke
// test.kt:8 invokeSuspend
// test.kt:9 invokeSuspend
// test.kt:-1 invoke
// test.kt:4 foo
// test.kt:8 box
// test.kt:11 box
@@ -379,6 +379,18 @@ public class IrSteppingTestGenerated extends AbstractIrSteppingTest {
runTest("compiler/testData/debug/stepping/stringSwitchesSmall.kt");
}
@Test
@TestMetadata("suspendFunWithLambdaParameter.kt")
public void testSuspendFunWithLambdaParameter() throws Exception {
runTest("compiler/testData/debug/stepping/suspendFunWithLambdaParameter.kt");
}
@Test
@TestMetadata("suspendFunWithSuspendLambdaParameter.kt")
public void testSuspendFunWithSuspendLambdaParameter() throws Exception {
runTest("compiler/testData/debug/stepping/suspendFunWithSuspendLambdaParameter.kt");
}
@Test
@TestMetadata("throwException.kt")
public void testThrowException() throws Exception {
@@ -379,6 +379,18 @@ public class SteppingTestGenerated extends AbstractSteppingTest {
runTest("compiler/testData/debug/stepping/stringSwitchesSmall.kt");
}
@Test
@TestMetadata("suspendFunWithLambdaParameter.kt")
public void testSuspendFunWithLambdaParameter() throws Exception {
runTest("compiler/testData/debug/stepping/suspendFunWithLambdaParameter.kt");
}
@Test
@TestMetadata("suspendFunWithSuspendLambdaParameter.kt")
public void testSuspendFunWithSuspendLambdaParameter() throws Exception {
runTest("compiler/testData/debug/stepping/suspendFunWithSuspendLambdaParameter.kt");
}
@Test
@TestMetadata("throwException.kt")
public void testThrowException() throws Exception {