JVM_IR KT-50073 inline callable reference adapter into 'invoke'

This commit is contained in:
Dmitry Petrov
2021-12-10 17:18:46 +03:00
committed by Space
parent 42dd8aa12d
commit 9375f41936
4 changed files with 113 additions and 18 deletions
@@ -57,6 +57,7 @@ import org.jetbrains.kotlin.utils.addToStdlib.safeAs
import org.jetbrains.org.objectweb.asm.*
import org.jetbrains.org.objectweb.asm.commons.Method
import java.io.File
import java.lang.RuntimeException
class ClassCodegen private constructor(
val irClass: IrClass,
@@ -141,7 +142,8 @@ class ClassCodegen private constructor(
for (method in irClass.declarations.filterIsInstance<IrFunction>()) {
if (method.name.asString() != "<clinit>" &&
method.origin != JvmLoweredDeclarationOrigin.INLINE_LAMBDA &&
method.origin != IrDeclarationOrigin.ADAPTER_FOR_FUN_INTERFACE_CONSTRUCTOR
method.origin != IrDeclarationOrigin.ADAPTER_FOR_FUN_INTERFACE_CONSTRUCTOR &&
!(method.origin == IrDeclarationOrigin.ADAPTER_FOR_CALLABLE_REFERENCE && method.body == null)
) {
generateMethod(method, smap)
}
@@ -481,7 +481,9 @@ class ExpressionCodegen(
fun handleValueParameter(i: Int, irParameter: IrValueParameter) {
val arg = expression.getValueArgument(i)
val parameterType = callable.valueParameterTypes[i]
require(arg != null) { "Null argument in ExpressionCodegen for parameter ${irParameter.render()}" }
require(arg != null) {
"No argument for parameter ${irParameter.render()}:\n${expression.dump()}"
}
callGenerator.genValueAndPut(irParameter, arg, parameterType, this, data)
}