[JVM+IR] Rebase LVT test of destructuing in lambda params
The debug experiece of destructuring patterns in lambdas is different across the two backends due to the IR backend moving local variables to fields. However, since the destructuring variable is never actually visible in the debugger (no linenumbers in the live range of the variable), and the variable is never used for anything other than hiding it from the debugger, we propose that it is not actually necessary to include it in the LVT (and in fact, could be left out of the LVT on the old backend).
This commit is contained in:
committed by
max-kammerer
parent
ccc272c49f
commit
18612c1ef0
-31
@@ -1,31 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
class A {
|
||||
operator fun component1() = "O"
|
||||
operator fun component2(): String = throw RuntimeException("fail 0")
|
||||
operator fun component3() = "K"
|
||||
}
|
||||
|
||||
suspend fun foo(a: A, block: suspend (A) -> String): String = block(a)
|
||||
|
||||
suspend fun test() = foo(A()) { (x_param, _, y_param) ->
|
||||
x_param + y_param
|
||||
}
|
||||
|
||||
// Parameters (including anonymous destructuring parameters) are moved to fields in the Continuation class for the suspend lambda class.
|
||||
// However, in non-IR, the fields are first stored in local variables, and they are not read directly (even for destructuring components).
|
||||
// In IR, the fields are directly read from.
|
||||
|
||||
// METHOD : UnderscoreNamesKt$test$2.invokeSuspend(Ljava/lang/Object;)Ljava/lang/Object;
|
||||
|
||||
// JVM_TEMPLATES
|
||||
// VARIABLE : NAME=$dstr$x_param$_u24__u24$y_param TYPE=LA; INDEX=2
|
||||
// VARIABLE : NAME=x_param TYPE=Ljava/lang/String; INDEX=3
|
||||
// VARIABLE : NAME=y_param TYPE=Ljava/lang/String; INDEX=4
|
||||
// VARIABLE : NAME=this TYPE=LUnderscoreNamesKt$test$2; INDEX=0
|
||||
// VARIABLE : NAME=$result TYPE=Ljava/lang/Object; INDEX=1
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// VARIABLE : NAME=x_param TYPE=Ljava/lang/String; INDEX=2
|
||||
// VARIABLE : NAME=y_param TYPE=Ljava/lang/String; INDEX=3
|
||||
// VARIABLE : NAME=this TYPE=LUnderscoreNamesKt$test$2; INDEX=0
|
||||
// VARIABLE : NAME=$result TYPE=Ljava/lang/Object; INDEX=1
|
||||
@@ -17,36 +17,50 @@ suspend fun box() = foo(A()) { (x_param, _, y_param) ->
|
||||
// However, in non-IR, the fields are first stored in local variables, and they are not read directly (even for destructuring components).
|
||||
// In IR, the fields are directly read from.
|
||||
|
||||
// METHOD : UnderscoreNamesKt$test$2.invokeSuspend(Ljava/lang/Object;)Ljava/lang/Object;
|
||||
// The local variable for destructuring suspend lambda arguments, in this case
|
||||
// `$dstr$x_param$_u24__u24$y_param`, is moved to a field in the IR backend,
|
||||
// so does not figure in the LVT.
|
||||
|
||||
// JVM_TEMPLATES
|
||||
// VARIABLE : NAME=x_param TYPE=Ljava/lang/String; INDEX=3
|
||||
// VARIABLE : NAME=y_param TYPE=Ljava/lang/String; INDEX=4
|
||||
// VARIABLE : NAME=this TYPE=LUnderscoreNamesKt$test$2; INDEX=0
|
||||
// VARIABLE : NAME=$result TYPE=Ljava/lang/Object; INDEX=1
|
||||
|
||||
// JVM_IR_TEMPLATES
|
||||
// VARIABLE : NAME=x_param TYPE=Ljava/lang/String; INDEX=2
|
||||
// VARIABLE : NAME=y_param TYPE=Ljava/lang/String; INDEX=3
|
||||
// VARIABLE : NAME=this TYPE=LUnderscoreNamesKt$test$2; INDEX=0
|
||||
// VARIABLE : NAME=$result TYPE=Ljava/lang/Object; INDEX=1
|
||||
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// LOCAL VARIABLES
|
||||
// test.kt:12 box: $completion:kotlin.coroutines.Continuation=helpers.ResultContinuation
|
||||
// test.kt:4 <init>:
|
||||
// test.kt:12 box: $completion:kotlin.coroutines.Continuation=helpers.ResultContinuation
|
||||
// test.kt:10 foo: a:A=A, block:kotlin.jvm.functions.Function2=TestKt$box$2, $completion:kotlin.coroutines.Continuation=helpers.ResultContinuation
|
||||
// CoroutineUtil.kt:28 getContext:
|
||||
|
||||
// LOCAL VARIABLES JVM
|
||||
// test.kt:-1 <init>:
|
||||
// test.kt:-1 create: value:java.lang.Object=A, completion:kotlin.coroutines.Continuation=helpers.ResultContinuation
|
||||
// test.kt:-1 invoke:
|
||||
|
||||
// LOCAL VARIABLES JVM_IR
|
||||
// test.kt:-1 <init>: $completion:kotlin.coroutines.Continuation=helpers.ResultContinuation
|
||||
// test.kt:-1 create: value:java.lang.Object=A, $completion:kotlin.coroutines.Continuation=helpers.ResultContinuation
|
||||
// test.kt:-1 invoke: p1:A=A, p2:kotlin.coroutines.Continuation=helpers.ResultContinuation
|
||||
|
||||
// LOCAL VARIABLES
|
||||
// test.kt:12 invokeSuspend:
|
||||
// test.kt:5 component1:
|
||||
|
||||
// LOCAL VARIABLES JVM
|
||||
// test.kt:12 invokeSuspend: $result:java.lang.Object=kotlin.Unit, $dstr$x_param$_u24__u24$y_param:A=A
|
||||
// test.kt:7 component3:
|
||||
// test.kt:12 invokeSuspend: $result:java.lang.Object=kotlin.Unit, $dstr$x_param$_u24__u24$y_param:A=A
|
||||
|
||||
// LOCAL VARIABLES JVM_IR
|
||||
// test.kt:12 invokeSuspend: $result:java.lang.Object=kotlin.Unit
|
||||
// test.kt:7 component3:
|
||||
// test.kt:12 invokeSuspend: $result:java.lang.Object=kotlin.Unit, x_param:java.lang.String="O":java.lang.String
|
||||
|
||||
// LOCAL VARIABLES
|
||||
// test.kt:13 invokeSuspend: $result:java.lang.Object=kotlin.Unit, x_param:java.lang.String="O":java.lang.String, y_param:java.lang.String="K":java.lang.String
|
||||
|
||||
// LOCAL VARIABLES JVM
|
||||
// test.kt:-1 invoke:
|
||||
|
||||
// LOCAL VARIABLES JVM_IR
|
||||
// test.kt:-1 invoke: p1:A=A, p2:kotlin.coroutines.Continuation=helpers.ResultContinuation
|
||||
|
||||
// LOCAL VARIABLES
|
||||
// test.kt:10 foo: a:A=A, block:kotlin.jvm.functions.Function2=TestKt$box$2, $completion:kotlin.coroutines.Continuation=helpers.ResultContinuation
|
||||
// test.kt:14 box: $completion:kotlin.coroutines.Continuation=helpers.ResultContinuation
|
||||
-5
@@ -188,10 +188,5 @@ public class CheckLocalVariablesTableTestGenerated extends AbstractCheckLocalVar
|
||||
public void testParameters() throws Exception {
|
||||
runTest("compiler/testData/checkLocalVariablesTable/parametersInSuspendLambda/parameters.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("underscoreNames.kt")
|
||||
public void testUnderscoreNames() throws Exception {
|
||||
runTest("compiler/testData/checkLocalVariablesTable/parametersInSuspendLambda/underscoreNames.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Generated
-5
@@ -188,10 +188,5 @@ public class IrCheckLocalVariablesTableTestGenerated extends AbstractIrCheckLoca
|
||||
public void testParameters() throws Exception {
|
||||
runTest("compiler/testData/checkLocalVariablesTable/parametersInSuspendLambda/parameters.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("underscoreNames.kt")
|
||||
public void testUnderscoreNames() throws Exception {
|
||||
runTest("compiler/testData/checkLocalVariablesTable/parametersInSuspendLambda/underscoreNames.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user