IR: use names $this/$receiver for receivers in copied static functions

Similarly to the other places in the IR backend (e.g. see
`copyValueParametersToStatic` in the same file).

In JVM IR, these names are used for example for receiver parameters of
methods copied to DefaultImpls classes. Since Java stub code generated
by kapt mentions them, it fixes a few issues in tests on kapt + JVM IR
(KT-49682).
This commit is contained in:
Alexander Udalov
2021-12-09 00:46:36 +01:00
parent f6d3bb5b1b
commit 1df2851611
4 changed files with 72 additions and 5 deletions
@@ -538,14 +538,14 @@ fun IrFactory.createStaticFunctionWithReceivers(
var offset = 0
val dispatchReceiver = oldFunction.dispatchReceiverParameter?.copyTo(
this,
name = Name.identifier("this"),
name = Name.identifier("\$this"),
index = offset++,
type = remap(dispatchReceiverType!!),
origin = IrDeclarationOrigin.MOVED_DISPATCH_RECEIVER
)
val extensionReceiver = oldFunction.extensionReceiverParameter?.copyTo(
this,
name = Name.identifier("receiver"),
name = Name.identifier("\$receiver"),
index = offset++,
origin = IrDeclarationOrigin.MOVED_EXTENSION_RECEIVER,
remapTypeMap = typeParameterMap
@@ -1,5 +1,3 @@
// IGNORE_BACKEND: JVM_IR
interface IntfWithoutDefaultImpls
interface IntfWithDefaultImpls {
@@ -0,0 +1,69 @@
import java.lang.System;
@kotlin.Metadata()
public abstract interface Intf {
public static final int WHITE = 2;
@org.jetbrains.annotations.NotNull()
public static final Intf.Companion Companion = null;
public abstract int getColor();
@kotlin.Metadata()
public static final class Companion {
private static final int BLACK = 1;
public static final int WHITE = 2;
private Companion() {
super();
}
public final int getBLACK() {
return 0;
}
}
@kotlin.Metadata()
public static final class DefaultImpls {
public DefaultImpls() {
super();
}
public static int getColor(@org.jetbrains.annotations.NotNull()
Intf $this) {
return 0;
}
}
}
////////////////////
import java.lang.System;
@kotlin.Metadata()
public abstract interface IntfWithDefaultImpls {
public abstract void a();
@kotlin.Metadata()
public static final class DefaultImpls {
public DefaultImpls() {
super();
}
public static void a(@org.jetbrains.annotations.NotNull()
IntfWithDefaultImpls $this) {
}
}
}
////////////////////
import java.lang.System;
@kotlin.Metadata()
public abstract interface IntfWithoutDefaultImpls {
}
@@ -876,7 +876,7 @@ public final class X$Companion : java/lang/Object {
}
public final class X$DefaultImpls : java/lang/Object {
public static void def(X this)
public static void def(X $this)
}
public abstract interface X : java/lang/Object {