Generate meaningful bytecode names for extension receivers in INDY lambdas

This commit is contained in:
Pavel Mikhailovskii
2022-11-14 17:15:36 +01:00
committed by teamcity
parent 2953e600ff
commit 4436ce22b0
4 changed files with 41 additions and 1 deletions
@@ -4267,6 +4267,12 @@ public class FirBytecodeTextTestGenerated extends AbstractFirBytecodeTextTest {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeText/invokedynamic"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("extensionReceiversNames.kt")
public void testExtensionReceiversNames() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/invokedynamic/extensionReceiversNames.kt");
}
@Test
@TestMetadata("functionRefToJavaInterface.kt")
public void testFunctionRefToJavaInterface() throws Exception {
@@ -446,7 +446,7 @@ internal class LambdaMetafactoryArgumentsBuilder(
var newParameterIndex = 0
newValueParameters.add(
oldExtensionReceiver.copy(lambda, newParameterIndex++, Name.identifier("\$receiver")).also {
oldExtensionReceiver.copy(lambda, newParameterIndex++, oldExtensionReceiver.name).also {
oldToNew[oldExtensionReceiver] = it
}
)
@@ -0,0 +1,28 @@
// LANGUAGE: +LightweightLambdas
// TARGET_BACKEND: JVM_IR
fun <T> block(t: T, f: T.() -> Unit) {
f.invoke(t)
}
fun test() {
block("first") place1@ {
block("second") place2@ {
// Breakpoint here
this@place1
this@place2
}
}
}
// JVM_IR_TEMPLATES
// 2 INVOKEDYNAMIC
// 0 receiver
// 5 LOCALVARIABLE
// 1 LOCALVARIABLE \$this\$place1
// 1 LOCALVARIABLE \$this\$place2
// 1 LOCALVARIABLE t
// 1 LOCALVARIABLE f
// 1 LOCALVARIABLE \$this_place1
// 1 LDC "\$this\$place1"
// 1 LDC "\$this\$place2"
@@ -4267,6 +4267,12 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeText/invokedynamic"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("extensionReceiversNames.kt")
public void testExtensionReceiversNames() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/invokedynamic/extensionReceiversNames.kt");
}
@Test
@TestMetadata("functionRefToJavaInterface.kt")
public void testFunctionRefToJavaInterface() throws Exception {