Drop all usages of inlineFunctionSymbol in IrReturnableBlock
This commit is contained in:
+1
-1
@@ -104,7 +104,7 @@ private fun IrBody.move(
|
||||
// TODO use a generic inliner (e.g. JS/Native's FunctionInlining.Inliner)
|
||||
// Inline simple function calls without type parameters, default parameters, or varargs.
|
||||
fun IrFunction.inline(target: IrDeclarationParent, arguments: List<IrValueDeclaration> = listOf()): IrReturnableBlock =
|
||||
IrReturnableBlockImpl(startOffset, endOffset, returnType, IrReturnableBlockSymbolImpl(), null, symbol).apply {
|
||||
IrReturnableBlockImpl(startOffset, endOffset, returnType, IrReturnableBlockSymbolImpl(), null).apply {
|
||||
statements += body!!.move(this@inline, target, symbol, explicitParameters.zip(arguments).toMap()).statements
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@ import org.jetbrains.kotlin.ir.expressions.impl.IrVarargImpl
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.ir.types.isUnit
|
||||
import org.jetbrains.kotlin.ir.types.typeWith
|
||||
import org.jetbrains.kotlin.ir.util.dump
|
||||
import org.jetbrains.kotlin.ir.util.statements
|
||||
|
||||
fun IrReturnTarget.returnType(context: CommonBackendContext) =
|
||||
when (this) {
|
||||
@@ -121,3 +123,24 @@ fun CommonBackendContext.createArrayOfExpression(
|
||||
}
|
||||
|
||||
fun IrFunction.isInlineFunWithReifiedParameter() = isInline && typeParameters.any { it.isReified }
|
||||
|
||||
// This code is partially duplicated in jvm FunctionReferenceLowering::adapteeCall
|
||||
// The difference is jvm version doesn't support ReturnableBlock, but returns call node instead of called function.
|
||||
fun IrFunction.getAdapteeFromAdaptedForReferenceFunction() : IrFunction? {
|
||||
if (origin != IrDeclarationOrigin.ADAPTER_FOR_CALLABLE_REFERENCE) return null
|
||||
// The body of a callable reference adapter contains either only a call, or an IMPLICIT_COERCION_TO_UNIT type operator
|
||||
// applied to a either a call or ReturnableBlock produced from that call inlining.
|
||||
// That call's target is the original function which we need to get.
|
||||
fun unknownStructure(): Nothing = throw UnsupportedOperationException("Unknown structure of ADAPTER_FOR_CALLABLE_REFERENCE: ${dump()}")
|
||||
val call = when (val statement = body?.statements?.singleOrNull() ?: unknownStructure()) {
|
||||
is IrTypeOperatorCall -> {
|
||||
if (statement.operator != IrTypeOperator.IMPLICIT_COERCION_TO_UNIT) unknownStructure()
|
||||
statement.argument
|
||||
}
|
||||
is IrReturn -> statement.value
|
||||
else -> statement
|
||||
}
|
||||
if (call is IrReturnableBlock) return call.inlineFunction ?: unknownStructure()
|
||||
if (call !is IrFunctionAccessExpression) unknownStructure()
|
||||
return call.symbol.owner
|
||||
}
|
||||
|
||||
-1
@@ -235,7 +235,6 @@ class FunctionInlining(
|
||||
symbol = irReturnableBlockSymbol,
|
||||
origin = null,
|
||||
statements = listOf(inlinedBlock),
|
||||
inlineFunctionSymbol = inlineFunctionResolver.getFunctionSymbol(callee)
|
||||
).apply {
|
||||
transformChildrenVoid(object : IrElementTransformerVoid() {
|
||||
override fun visitReturn(expression: IrReturn): IrExpression {
|
||||
|
||||
Reference in New Issue
Block a user