IR: make IrCall take IrSimpleFunctionSymbol

This commit is contained in:
Georgy Bronnikov
2020-08-10 13:02:44 +03:00
parent 4901cdb11f
commit 18ae665d41
30 changed files with 124 additions and 100 deletions
@@ -288,10 +288,10 @@ class CallAndReferenceGenerator(
val startOffset = adapteeFunction.startOffset val startOffset = adapteeFunction.startOffset
val endOffset = adapteeFunction.endOffset val endOffset = adapteeFunction.endOffset
val type = adapteeFunction.returnType val type = adapteeFunction.returnType
val irCall = val irCall = when (adapteeSymbol) {
if (adapteeSymbol is IrConstructorSymbol) { is IrConstructorSymbol ->
IrConstructorCallImpl.fromSymbolOwner(startOffset, endOffset, type, adapteeSymbol) IrConstructorCallImpl.fromSymbolOwner(startOffset, endOffset, type, adapteeSymbol)
} else { is IrSimpleFunctionSymbol ->
IrCallImpl( IrCallImpl(
startOffset, startOffset,
endOffset, endOffset,
@@ -302,7 +302,9 @@ class CallAndReferenceGenerator(
origin = null, origin = null,
superQualifierSymbol = null superQualifierSymbol = null
) )
} else ->
error("unknown callee kind: ${adapteeFunction.render()}")
}
if (boundDispatchReceiver != null || boundExtensionReceiver != null) { if (boundDispatchReceiver != null || boundExtensionReceiver != null) {
val receiverValue = IrGetValueImpl( val receiverValue = IrGetValueImpl(
@@ -341,7 +341,7 @@ open class DefaultParameterInjector(
return visitFunctionAccessExpression(expression) { return visitFunctionAccessExpression(expression) {
with(expression) { with(expression) {
IrCallImpl( IrCallImpl(
startOffset, endOffset, type, it, startOffset, endOffset, type, it as IrSimpleFunctionSymbol,
typeArgumentsCount = typeArgumentsCount, typeArgumentsCount = typeArgumentsCount,
valueArgumentsCount = it.owner.valueParameters.size, valueArgumentsCount = it.owner.valueParameters.size,
origin = DEFAULT_DISPATCH_CALL, origin = DEFAULT_DISPATCH_CALL,
@@ -509,7 +509,7 @@ class LocalDeclarationsLowering(
rewriteFunctionBody(irElement, null) rewriteFunctionBody(irElement, null)
} }
private fun createNewCall(oldCall: IrCall, newCallee: IrFunction) = private fun createNewCall(oldCall: IrCall, newCallee: IrSimpleFunction) =
IrCallImpl( IrCallImpl(
oldCall.startOffset, oldCall.endOffset, oldCall.startOffset, oldCall.endOffset,
newCallee.returnType, newCallee.returnType,
@@ -234,17 +234,22 @@ class FunctionInlining(
} }
val immediateCall = with(expression) { val immediateCall = with(expression) {
if (function is IrConstructor) { when (function) {
val classTypeParametersCount = function.parentAsClass.typeParameters.size is IrConstructor -> {
IrConstructorCallImpl.fromSymbolOwner( val classTypeParametersCount = function.parentAsClass.typeParameters.size
startOffset, IrConstructorCallImpl.fromSymbolOwner(
endOffset, startOffset,
function.returnType, endOffset,
function.symbol, function.returnType,
classTypeParametersCount function.symbol,
) classTypeParametersCount
} else )
IrCallImpl(startOffset, endOffset, function.returnType, functionArgument.symbol) }
is IrSimpleFunction ->
IrCallImpl(startOffset, endOffset, function.returnType, function.symbol)
else ->
error("Unknown function kind : ${function.render()}")
}
}.apply { }.apply {
for (parameter in functionParameters) { for (parameter in functionParameters) {
val argument = val argument =
@@ -21,7 +21,7 @@ object JsIrBuilder {
object SYNTHESIZED_STATEMENT : IrStatementOriginImpl("SYNTHESIZED_STATEMENT") object SYNTHESIZED_STATEMENT : IrStatementOriginImpl("SYNTHESIZED_STATEMENT")
object SYNTHESIZED_DECLARATION : IrDeclarationOriginImpl("SYNTHESIZED_DECLARATION") object SYNTHESIZED_DECLARATION : IrDeclarationOriginImpl("SYNTHESIZED_DECLARATION")
fun buildCall(target: IrFunctionSymbol, type: IrType? = null, typeArguments: List<IrType>? = null): IrCall { fun buildCall(target: IrSimpleFunctionSymbol, type: IrType? = null, typeArguments: List<IrType>? = null): IrCall {
val owner = target.owner val owner = target.owner
return IrCallImpl( return IrCallImpl(
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
@@ -22,10 +22,7 @@ import org.jetbrains.kotlin.ir.expressions.impl.*
import org.jetbrains.kotlin.ir.types.IrSimpleType import org.jetbrains.kotlin.ir.types.IrSimpleType
import org.jetbrains.kotlin.ir.types.IrTypeProjection import org.jetbrains.kotlin.ir.types.IrTypeProjection
import org.jetbrains.kotlin.ir.types.classOrNull import org.jetbrains.kotlin.ir.types.classOrNull
import org.jetbrains.kotlin.ir.util.defaultType import org.jetbrains.kotlin.ir.util.*
import org.jetbrains.kotlin.ir.util.explicitParameters
import org.jetbrains.kotlin.ir.util.isSuspend
import org.jetbrains.kotlin.ir.util.parentAsClass
import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid
import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.Name
@@ -220,10 +217,30 @@ class CallableReferenceLowering(private val context: CommonBackendContext) : Bod
private fun IrSimpleFunction.buildInvoke(): IrFunctionAccessExpression { private fun IrSimpleFunction.buildInvoke(): IrFunctionAccessExpression {
val callee = function val callee = function
val irCall = reference.run { val irCall = reference.run {
if (callee is IrConstructor) { when (callee) {
IrConstructorCallImpl(startOffset, endOffset, callee.parentAsClass.defaultType, callee.symbol, callee.typeParameters.size, 0 /* TODO */, callee.valueParameters.size, CALLABLE_REFERENCE_INVOKE) is IrConstructor ->
} else { IrConstructorCallImpl(
IrCallImpl(startOffset, endOffset, callee.returnType, callee.symbol, callee.typeParameters.size, callee.valueParameters.size, CALLABLE_REFERENCE_INVOKE) startOffset,
endOffset,
callee.parentAsClass.defaultType,
callee.symbol,
callee.typeParameters.size,
0 /* TODO */,
callee.valueParameters.size,
CALLABLE_REFERENCE_INVOKE
)
is IrSimpleFunction ->
IrCallImpl(
startOffset,
endOffset,
callee.returnType,
callee.symbol,
callee.typeParameters.size,
callee.valueParameters.size,
CALLABLE_REFERENCE_INVOKE
)
else ->
error("unknown function kind: ${callee.render()}")
} }
} }
@@ -121,7 +121,7 @@ class CreateScriptFunctionsPhase(val context: CommonBackendContext) : FileLoweri
) )
} }
private fun createCall(function: IrFunction): IrCall { private fun createCall(function: IrSimpleFunction): IrCall {
return IrCallImpl( return IrCallImpl(
UNDEFINED_OFFSET, UNDEFINED_OFFSET, function.returnType, UNDEFINED_OFFSET, UNDEFINED_OFFSET, function.returnType,
function.symbol, function.symbol,
@@ -5,19 +5,19 @@
package org.jetbrains.kotlin.ir.backend.js.lower.calls package org.jetbrains.kotlin.ir.backend.js.lower.calls
import org.jetbrains.kotlin.ir.declarations.IrFunction import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
import org.jetbrains.kotlin.ir.expressions.IrExpression import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrFunctionAccessExpression import org.jetbrains.kotlin.ir.expressions.IrFunctionAccessExpression
import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
import org.jetbrains.kotlin.ir.types.* import org.jetbrains.kotlin.ir.types.*
import org.jetbrains.kotlin.ir.util.irCall import org.jetbrains.kotlin.ir.util.irCall
import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.types.SimpleType
typealias SymbolToTransformer = MutableMap<IrFunctionSymbol, (IrFunctionAccessExpression) -> IrExpression> typealias SymbolToTransformer = MutableMap<IrFunctionSymbol, (IrFunctionAccessExpression) -> IrExpression>
internal fun SymbolToTransformer.add(from: Map<IrClassifierSymbol, IrFunctionSymbol>, to: IrFunctionSymbol) { internal fun SymbolToTransformer.add(from: Map<IrClassifierSymbol, IrFunctionSymbol>, to: IrSimpleFunctionSymbol) {
from.forEach { _, func -> from.forEach { _, func ->
add(func, to) add(func, to)
} }
@@ -33,7 +33,7 @@ internal fun SymbolToTransformer.add(from: IrFunctionSymbol, to: (IrFunctionAcce
put(from, to) put(from, to)
} }
internal fun SymbolToTransformer.add(from: IrFunctionSymbol, to: IrFunctionSymbol, dispatchReceiverAsFirstArgument: Boolean = false) { internal fun SymbolToTransformer.add(from: IrFunctionSymbol, to: IrSimpleFunctionSymbol, dispatchReceiverAsFirstArgument: Boolean = false) {
put(from) { call -> irCall(call, to, dispatchReceiverAsFirstArgument) } put(from) { call -> irCall(call, to, dispatchReceiverAsFirstArgument) }
} }
@@ -47,11 +47,11 @@ internal fun <K> MutableMap<K, (IrFunctionAccessExpression) -> IrExpression>.add
internal typealias MemberToTransformer = HashMap<SimpleMemberKey, (IrFunctionAccessExpression) -> IrExpression> internal typealias MemberToTransformer = HashMap<SimpleMemberKey, (IrFunctionAccessExpression) -> IrExpression>
internal fun MemberToTransformer.add(type: IrType, name: Name, v: IrFunctionSymbol) { internal fun MemberToTransformer.add(type: IrType, name: Name, v: IrSimpleFunctionSymbol) {
add(type, name) { irCall(it, v, receiversAsArguments = true) } add(type, name) { irCall(it, v, receiversAsArguments = true) }
} }
internal fun MemberToTransformer.add(type: IrType, name: Name, v: IrFunction) { internal fun MemberToTransformer.add(type: IrType, name: Name, v: IrSimpleFunction) {
add(type, name, v.symbol) add(type, name, v.symbol)
} }
@@ -13,6 +13,7 @@ import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrFunctionAccessExpression import org.jetbrains.kotlin.ir.expressions.IrFunctionAccessExpression
import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
import org.jetbrains.kotlin.ir.types.* import org.jetbrains.kotlin.ir.types.*
import org.jetbrains.kotlin.ir.util.irCall import org.jetbrains.kotlin.ir.util.irCall
import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.Name
@@ -117,7 +118,7 @@ class NumberOperatorCallsTransformer(context: JsIrBackendContext) : CallsTransfo
private fun irBinaryOp( private fun irBinaryOp(
call: IrFunctionAccessExpression, call: IrFunctionAccessExpression,
intrinsic: IrFunctionSymbol, intrinsic: IrSimpleFunctionSymbol,
toInt32: Boolean = false toInt32: Boolean = false
): IrExpression { ): IrExpression {
val newCall = irCall(call, intrinsic, receiversAsArguments = true) val newCall = irCall(call, intrinsic, receiversAsArguments = true)
@@ -170,7 +171,7 @@ class NumberOperatorCallsTransformer(context: JsIrBackendContext) : CallsTransfo
private fun transformDecrement(call: IrFunctionAccessExpression) = private fun transformDecrement(call: IrFunctionAccessExpression) =
transformCrement(call, intrinsics.jsMinus) transformCrement(call, intrinsics.jsMinus)
private fun transformCrement(call: IrFunctionAccessExpression, correspondingBinaryOp: IrFunctionSymbol): IrExpression { private fun transformCrement(call: IrFunctionAccessExpression, correspondingBinaryOp: IrSimpleFunctionSymbol): IrExpression {
val operation = irCall(call, correspondingBinaryOp, receiversAsArguments = true).apply { val operation = irCall(call, correspondingBinaryOp, receiversAsArguments = true).apply {
putValueArgument(1, buildInt(1)) putValueArgument(1, buildInt(1))
} }
@@ -262,7 +263,7 @@ class NumberOperatorCallsTransformer(context: JsIrBackendContext) : CallsTransfo
} }
} }
fun IrFunctionSymbol.call(vararg arguments: IrExpression) = fun IrSimpleFunctionSymbol.call(vararg arguments: IrExpression) =
JsIrBuilder.buildCall(this, owner.returnType).apply { JsIrBuilder.buildCall(this, owner.returnType).apply {
for ((idx, arg) in arguments.withIndex()) { for ((idx, arg) in arguments.withIndex()) {
putValueArgument(idx, arg) putValueArgument(idx, arg)
@@ -101,7 +101,7 @@ class JvmBackendContext(
internal val multifileFacadesToAdd = mutableMapOf<JvmClassName, MutableList<IrClass>>() internal val multifileFacadesToAdd = mutableMapOf<JvmClassName, MutableList<IrClass>>()
val multifileFacadeForPart = mutableMapOf<IrClass, JvmClassName>() val multifileFacadeForPart = mutableMapOf<IrClass, JvmClassName>()
internal val multifileFacadeClassForPart = mutableMapOf<IrClass, IrClass>() internal val multifileFacadeClassForPart = mutableMapOf<IrClass, IrClass>()
internal val multifileFacadeMemberToPartMember = mutableMapOf<IrFunction, IrFunction>() internal val multifileFacadeMemberToPartMember = mutableMapOf<IrSimpleFunction, IrSimpleFunction>()
internal val hiddenConstructors = mutableMapOf<IrConstructor, IrConstructor>() internal val hiddenConstructors = mutableMapOf<IrConstructor, IrConstructor>()
@@ -117,7 +117,7 @@ class JvmBackendContext(
val suspendFunctionOriginalToView = mutableMapOf<IrFunction, IrFunction>() val suspendFunctionOriginalToView = mutableMapOf<IrFunction, IrFunction>()
val fakeContinuation: IrExpression = createFakeContinuation(this) val fakeContinuation: IrExpression = createFakeContinuation(this)
val staticDefaultStubs = mutableMapOf<IrFunctionSymbol, IrFunction>() val staticDefaultStubs = mutableMapOf<IrSimpleFunctionSymbol, IrSimpleFunction>()
val inlineClassReplacements = MemoizedInlineClassReplacements(state.functionsWithInlineClassReturnTypesMangled, irFactory) val inlineClassReplacements = MemoizedInlineClassReplacements(state.functionsWithInlineClassReturnTypesMangled, irFactory)
@@ -268,7 +268,11 @@ fun IrBody.replaceThisByStaticReference(
fun createPlaceholderAnyNType(irBuiltIns: IrBuiltIns): IrType = fun createPlaceholderAnyNType(irBuiltIns: IrBuiltIns): IrType =
irBuiltIns.anyNType irBuiltIns.anyNType
fun createDelegatingCallWithPlaceholderTypeArguments(existingCall: IrCall, redirectTarget: IrFunction, irBuiltIns: IrBuiltIns): IrCall = fun createDelegatingCallWithPlaceholderTypeArguments(
existingCall: IrCall,
redirectTarget: IrSimpleFunction,
irBuiltIns: IrBuiltIns
): IrCall =
IrCallImpl( IrCallImpl(
existingCall.startOffset, existingCall.startOffset,
existingCall.endOffset, existingCall.endOffset,
@@ -47,7 +47,7 @@ internal val generateMultifileFacadesPhase = makeCustomPhase<JvmBackendContext,
description = "Generate JvmMultifileClass facades, based on the information provided by FileClassLowering", description = "Generate JvmMultifileClass facades, based on the information provided by FileClassLowering",
prerequisite = setOf(fileClassPhase), prerequisite = setOf(fileClassPhase),
op = { context, input -> op = { context, input ->
val functionDelegates = mutableMapOf<IrFunction, IrFunction>() val functionDelegates = mutableMapOf<IrSimpleFunction, IrSimpleFunction>()
// In -Xmultifile-parts-inherit mode, instead of generating "bridge" methods in the facade which call into parts, // In -Xmultifile-parts-inherit mode, instead of generating "bridge" methods in the facade which call into parts,
// we construct an inheritance chain such that all part members are present as fake overrides in the facade. // we construct an inheritance chain such that all part members are present as fake overrides in the facade.
@@ -89,7 +89,7 @@ private fun generateMultifileFacades(
module: ModuleDescriptor, module: ModuleDescriptor,
context: JvmBackendContext, context: JvmBackendContext,
shouldGeneratePartHierarchy: Boolean, shouldGeneratePartHierarchy: Boolean,
functionDelegates: MutableMap<IrFunction, IrFunction> functionDelegates: MutableMap<IrSimpleFunction, IrSimpleFunction>
): List<IrFile> = ): List<IrFile> =
context.multifileFacadesToAdd.map { (jvmClassName, partClasses) -> context.multifileFacadesToAdd.map { (jvmClassName, partClasses) ->
val kotlinPackageFqName = partClasses.first().fqNameWhenAvailable!!.parent() val kotlinPackageFqName = partClasses.first().fqNameWhenAvailable!!.parent()
@@ -250,7 +250,7 @@ private fun IrSimpleFunction.createMultifileDelegateIfNeeded(
} }
private class UpdateFunctionCallSites( private class UpdateFunctionCallSites(
private val functionDelegates: MutableMap<IrFunction, IrFunction> private val functionDelegates: MutableMap<IrSimpleFunction, IrSimpleFunction>
) : FileLoweringPass, IrElementTransformer<IrFunction?> { ) : FileLoweringPass, IrElementTransformer<IrFunction?> {
override fun lower(irFile: IrFile) { override fun lower(irFile: IrFile) {
irFile.transformChildren(this, null) irFile.transformChildren(this, null)
@@ -21,8 +21,8 @@ import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrFunctionReference import org.jetbrains.kotlin.ir.expressions.IrFunctionReference
import org.jetbrains.kotlin.ir.expressions.IrReturn import org.jetbrains.kotlin.ir.expressions.IrReturn
import org.jetbrains.kotlin.ir.expressions.impl.* import org.jetbrains.kotlin.ir.expressions.impl.*
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
import org.jetbrains.kotlin.ir.symbols.IrLocalDelegatedPropertySymbol import org.jetbrains.kotlin.ir.symbols.IrLocalDelegatedPropertySymbol
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
import org.jetbrains.kotlin.ir.types.defaultType import org.jetbrains.kotlin.ir.types.defaultType
import org.jetbrains.kotlin.ir.util.* import org.jetbrains.kotlin.ir.util.*
import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid
@@ -36,7 +36,7 @@ import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
*/ */
internal class InterfaceLowering(val context: JvmBackendContext) : IrElementTransformerVoid(), ClassLoweringPass { internal class InterfaceLowering(val context: JvmBackendContext) : IrElementTransformerVoid(), ClassLoweringPass {
private val removedFunctions = hashMapOf<IrFunctionSymbol, IrFunctionSymbol>() private val removedFunctions = hashMapOf<IrSimpleFunctionSymbol, IrSimpleFunctionSymbol>()
override fun lower(irClass: IrClass) { override fun lower(irClass: IrClass) {
if (!irClass.isJvmInterface) return if (!irClass.isJvmInterface) return
@@ -199,7 +199,7 @@ internal class InterfaceLowering(val context: JvmBackendContext) : IrElementTran
// Bridge from static to static method - simply fill the function arguments to the parameters. // Bridge from static to static method - simply fill the function arguments to the parameters.
// By nature of the generation of both source and target of bridge, they line up. // By nature of the generation of both source and target of bridge, they line up.
private fun IrFunction.bridgeToStatic(callTarget: IrFunction) { private fun IrFunction.bridgeToStatic(callTarget: IrSimpleFunction) {
body = IrExpressionBodyImpl(IrCallImpl(startOffset, endOffset, returnType, callTarget.symbol).also { call -> body = IrExpressionBodyImpl(IrCallImpl(startOffset, endOffset, returnType, callTarget.symbol).also { call ->
callTarget.typeParameters.forEachIndexed { i, _ -> callTarget.typeParameters.forEachIndexed { i, _ ->
@@ -214,7 +214,7 @@ internal class InterfaceLowering(val context: JvmBackendContext) : IrElementTran
// Bridge from static DefaultImpl method to the interface method. Arguments need to // Bridge from static DefaultImpl method to the interface method. Arguments need to
// be shifted in presence of dispatch and extension receiver. // be shifted in presence of dispatch and extension receiver.
private fun IrFunction.bridgeViaAccessorTo(callTarget: IrFunction) { private fun IrFunction.bridgeViaAccessorTo(callTarget: IrSimpleFunction) {
body = IrExpressionBodyImpl( body = IrExpressionBodyImpl(
IrCallImpl( IrCallImpl(
startOffset, startOffset,
@@ -22,6 +22,7 @@ import org.jetbrains.kotlin.ir.types.defaultType
import org.jetbrains.kotlin.ir.util.allTypeParameters import org.jetbrains.kotlin.ir.util.allTypeParameters
import org.jetbrains.kotlin.ir.util.deepCopyWithSymbols import org.jetbrains.kotlin.ir.util.deepCopyWithSymbols
import org.jetbrains.kotlin.ir.util.hasAnnotation import org.jetbrains.kotlin.ir.util.hasAnnotation
import org.jetbrains.kotlin.ir.util.render
import org.jetbrains.kotlin.resolve.jvm.annotations.JVM_OVERLOADS_FQ_NAME import org.jetbrains.kotlin.resolve.jvm.annotations.JVM_OVERLOADS_FQ_NAME
internal val jvmOverloadsAnnotationPhase = makeIrFilePhase( internal val jvmOverloadsAnnotationPhase = makeIrFilePhase(
@@ -55,10 +56,14 @@ private class JvmOverloadsAnnotationLowering(val context: JvmBackendContext) : C
private fun generateWrapper(target: IrFunction, numDefaultParametersToExpect: Int): IrFunction { private fun generateWrapper(target: IrFunction, numDefaultParametersToExpect: Int): IrFunction {
val wrapperIrFunction = context.irFactory.generateWrapperHeader(target, numDefaultParametersToExpect) val wrapperIrFunction = context.irFactory.generateWrapperHeader(target, numDefaultParametersToExpect)
val call = if (target is IrConstructor) val call = when (target) {
IrDelegatingConstructorCallImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, context.irBuiltIns.unitType, target.symbol) is IrConstructor ->
else IrDelegatingConstructorCallImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, context.irBuiltIns.unitType, target.symbol)
IrCallImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, target.returnType, target.symbol) is IrSimpleFunction ->
IrCallImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, target.returnType, target.symbol)
else ->
error("unknown function kind: ${target.render()}")
}
for (arg in wrapperIrFunction.allTypeParameters) { for (arg in wrapperIrFunction.allTypeParameters) {
call.putTypeArgument(arg.index, arg.defaultType) call.putTypeArgument(arg.index, arg.defaultType)
} }
@@ -13,7 +13,7 @@ import org.jetbrains.kotlin.ir.declarations.IrFile
import org.jetbrains.kotlin.ir.expressions.IrCall import org.jetbrains.kotlin.ir.expressions.IrCall
import org.jetbrains.kotlin.ir.expressions.IrExpression import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.fqNameForIrSerialization import org.jetbrains.kotlin.ir.util.fqNameForIrSerialization
import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid
@@ -59,7 +59,7 @@ class JvmStandardLibraryBuiltInsLowering(val context: JvmBackendContext) : FileL
// Originals are so far only instance methods, and the replacements are // Originals are so far only instance methods, and the replacements are
// statics, so we copy dispatch receivers to a value argument if needed. // statics, so we copy dispatch receivers to a value argument if needed.
private fun IrCall.replaceWithCallTo(replacement: IrFunctionSymbol) = private fun IrCall.replaceWithCallTo(replacement: IrSimpleFunctionSymbol) =
IrCallImpl( IrCallImpl(
startOffset, startOffset,
endOffset, endOffset,
@@ -60,7 +60,7 @@ class ResolveInlineCalls(val context: JvmBackendContext) : IrElementTransformerV
}) })
} }
private fun IrFunction.resolveMultiFileFacades(): IrFunction? = private fun IrFunction.resolveMultiFileFacades(): IrSimpleFunction? =
if (origin == JvmLoweredDeclarationOrigin.MULTIFILE_BRIDGE) { if (origin == JvmLoweredDeclarationOrigin.MULTIFILE_BRIDGE) {
context.multifileFacadeMemberToPartMember[this] context.multifileFacadeMemberToPartMember[this]
} else null } else null
@@ -25,10 +25,7 @@ import org.jetbrains.kotlin.backend.common.phaser.makeIrFilePhase
import org.jetbrains.kotlin.backend.common.phaser.then import org.jetbrains.kotlin.backend.common.phaser.then
import org.jetbrains.kotlin.backend.jvm.JvmBackendContext import org.jetbrains.kotlin.backend.jvm.JvmBackendContext
import org.jetbrains.kotlin.ir.IrStatement import org.jetbrains.kotlin.ir.IrStatement
import org.jetbrains.kotlin.ir.declarations.IrClass import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
import org.jetbrains.kotlin.ir.declarations.IrFile
import org.jetbrains.kotlin.ir.declarations.IrFunction
import org.jetbrains.kotlin.ir.expressions.IrCall import org.jetbrains.kotlin.ir.expressions.IrCall
import org.jetbrains.kotlin.ir.expressions.IrExpression import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrReturn import org.jetbrains.kotlin.ir.expressions.IrReturn
@@ -63,7 +60,7 @@ private class StaticDefaultFunctionLowering(val context: JvmBackendContext) : Ir
irClass.accept(this, null) irClass.accept(this, null)
} }
override fun visitFunction(declaration: IrFunction): IrStatement = super.visitFunction( override fun visitSimpleFunction(declaration: IrSimpleFunction): IrStatement = super.visitFunction(
if (declaration.origin == IrDeclarationOrigin.FUNCTION_FOR_DEFAULT_PARAMETER && declaration.dispatchReceiverParameter != null) if (declaration.origin == IrDeclarationOrigin.FUNCTION_FOR_DEFAULT_PARAMETER && declaration.dispatchReceiverParameter != null)
context.getStaticFunctionWithReceivers(declaration).also { context.getStaticFunctionWithReceivers(declaration).also {
it.body = declaration.moveBodyTo(it) it.body = declaration.moveBodyTo(it)
@@ -106,7 +103,7 @@ private class StaticDefaultCallLowering(
} }
} }
private fun JvmBackendContext.getStaticFunctionWithReceivers(function: IrFunction) = private fun JvmBackendContext.getStaticFunctionWithReceivers(function: IrSimpleFunction) =
staticDefaultStubs.getOrPut(function.symbol) { staticDefaultStubs.getOrPut(function.symbol) {
irFactory.createStaticFunctionWithReceivers(function.parent, function.name, function) irFactory.createStaticFunctionWithReceivers(function.parent, function.name, function)
} }
@@ -313,7 +313,7 @@ internal class SyntheticAccessorLowering(val context: JvmBackendContext) : IrEle
} }
} }
private fun createSimpleFunctionCall(accessor: IrFunction, targetSymbol: IrFunctionSymbol, superQualifierSymbol: IrClassSymbol?) = private fun createSimpleFunctionCall(accessor: IrFunction, targetSymbol: IrSimpleFunctionSymbol, superQualifierSymbol: IrClassSymbol?) =
IrCallImpl( IrCallImpl(
UNDEFINED_OFFSET, UNDEFINED_OFFSET, UNDEFINED_OFFSET, UNDEFINED_OFFSET,
accessor.returnType, accessor.returnType,
@@ -410,7 +410,7 @@ internal class SyntheticAccessorLowering(val context: JvmBackendContext) : IrEle
is IrCall -> IrCallImpl( is IrCall -> IrCallImpl(
oldExpression.startOffset, oldExpression.endOffset, oldExpression.startOffset, oldExpression.endOffset,
oldExpression.type, oldExpression.type,
accessorSymbol, oldExpression.typeArgumentsCount, accessorSymbol as IrSimpleFunctionSymbol, oldExpression.typeArgumentsCount,
oldExpression.origin oldExpression.origin
) )
is IrDelegatingConstructorCall -> IrDelegatingConstructorCallImpl( is IrDelegatingConstructorCall -> IrDelegatingConstructorCallImpl(
@@ -447,7 +447,7 @@ internal class SyntheticAccessorLowering(val context: JvmBackendContext) : IrEle
private fun modifyGetterExpression( private fun modifyGetterExpression(
oldExpression: IrGetField, oldExpression: IrGetField,
accessorSymbol: IrFunctionSymbol accessorSymbol: IrSimpleFunctionSymbol
): IrCall { ): IrCall {
val call = IrCallImpl( val call = IrCallImpl(
oldExpression.startOffset, oldExpression.endOffset, oldExpression.startOffset, oldExpression.endOffset,
@@ -463,7 +463,7 @@ internal class SyntheticAccessorLowering(val context: JvmBackendContext) : IrEle
private fun modifySetterExpression( private fun modifySetterExpression(
oldExpression: IrSetField, oldExpression: IrSetField,
accessorSymbol: IrFunctionSymbol accessorSymbol: IrSimpleFunctionSymbol
): IrCall { ): IrCall {
val call = IrCallImpl( val call = IrCallImpl(
oldExpression.startOffset, oldExpression.endOffset, oldExpression.startOffset, oldExpression.endOffset,
@@ -28,7 +28,6 @@ import org.jetbrains.kotlin.ir.builders.irGet
import org.jetbrains.kotlin.ir.builders.irTemporary import org.jetbrains.kotlin.ir.builders.irTemporary
import org.jetbrains.kotlin.ir.expressions.* import org.jetbrains.kotlin.ir.expressions.*
import org.jetbrains.kotlin.ir.expressions.impl.IrDynamicOperatorExpressionImpl import org.jetbrains.kotlin.ir.expressions.impl.IrDynamicOperatorExpressionImpl
import org.jetbrains.kotlin.ir.util.referenceFunction
import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.endOffset import org.jetbrains.kotlin.psi.psiUtil.endOffset
@@ -317,8 +316,8 @@ class AssignmentGenerator(statementGenerator: StatementGenerator) : StatementGen
val getterDescriptor = unwrappedPropertyDescriptor.unwrappedGetMethod val getterDescriptor = unwrappedPropertyDescriptor.unwrappedGetMethod
val setterDescriptor = unwrappedPropertyDescriptor.unwrappedSetMethod val setterDescriptor = unwrappedPropertyDescriptor.unwrappedSetMethod
val getterSymbol = getterDescriptor?.let { context.symbolTable.referenceFunction(it.original) } val getterSymbol = getterDescriptor?.let { context.symbolTable.referenceSimpleFunction(it.original) }
val setterSymbol = setterDescriptor?.let { context.symbolTable.referenceFunction(it.original) } val setterSymbol = setterDescriptor?.let { context.symbolTable.referenceSimpleFunction(it.original) }
val propertyIrType = descriptor.type.toIrType() val propertyIrType = descriptor.type.toIrType()
return if (getterSymbol != null || setterSymbol != null) { return if (getterSymbol != null || setterSymbol != null) {
@@ -23,7 +23,6 @@ import org.jetbrains.kotlin.ir.expressions.*
import org.jetbrains.kotlin.ir.expressions.impl.* import org.jetbrains.kotlin.ir.expressions.impl.*
import org.jetbrains.kotlin.ir.types.IrDynamicType import org.jetbrains.kotlin.ir.types.IrDynamicType
import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.referenceFunction
import org.jetbrains.kotlin.ir.util.render import org.jetbrains.kotlin.ir.util.render
import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.psi.KtElement
import org.jetbrains.kotlin.psi.psiUtil.endOffset import org.jetbrains.kotlin.psi.psiUtil.endOffset
@@ -122,7 +121,7 @@ class CallGenerator(statementGenerator: StatementGenerator) : StatementGenerator
) = ) =
if (descriptor is LocalVariableDescriptor && descriptor.isDelegated) { if (descriptor is LocalVariableDescriptor && descriptor.isDelegated) {
val getterDescriptor = descriptor.getter!! val getterDescriptor = descriptor.getter!!
val getterSymbol = context.symbolTable.referenceFunction(getterDescriptor.original) val getterSymbol = context.symbolTable.referenceSimpleFunction(getterDescriptor.original)
IrCallImpl( IrCallImpl(
startOffset, endOffset, descriptor.type.toIrType(), getterSymbol, origin ?: IrStatementOrigin.GET_LOCAL_PROPERTY startOffset, endOffset, descriptor.type.toIrType(), getterSymbol, origin ?: IrStatementOrigin.GET_LOCAL_PROPERTY
).apply { ).apply {
@@ -207,7 +206,7 @@ class CallGenerator(statementGenerator: StatementGenerator) : StatementGenerator
dispatchReceiver dispatchReceiver
) )
} else { } else {
val getterSymbol = context.symbolTable.referenceFunction(getMethodDescriptor.original) val getterSymbol = context.symbolTable.referenceSimpleFunction(getMethodDescriptor.original)
IrCallImpl( IrCallImpl(
startOffset, endOffset, startOffset, endOffset,
irType, irType,
@@ -333,7 +332,7 @@ class CallGenerator(statementGenerator: StatementGenerator) : StatementGenerator
) )
} }
} else { } else {
val originalSymbol = context.symbolTable.referenceFunction(functionDescriptor.original) val originalSymbol = context.symbolTable.referenceSimpleFunction(functionDescriptor.original)
IrCallImpl( IrCallImpl(
startOffset, endOffset, startOffset, endOffset,
irType, irType,
@@ -32,7 +32,6 @@ import org.jetbrains.kotlin.ir.expressions.typeParametersCount
import org.jetbrains.kotlin.ir.util.createIrClassFromDescriptor import org.jetbrains.kotlin.ir.util.createIrClassFromDescriptor
import org.jetbrains.kotlin.ir.util.declareSimpleFunctionWithOverrides import org.jetbrains.kotlin.ir.util.declareSimpleFunctionWithOverrides
import org.jetbrains.kotlin.ir.util.properties import org.jetbrains.kotlin.ir.util.properties
import org.jetbrains.kotlin.ir.util.referenceFunction
import org.jetbrains.kotlin.psi.KtClassOrObject import org.jetbrains.kotlin.psi.KtClassOrObject
import org.jetbrains.kotlin.psi.KtDelegatedSuperTypeEntry import org.jetbrains.kotlin.psi.KtDelegatedSuperTypeEntry
import org.jetbrains.kotlin.psi.KtEnumEntry import org.jetbrains.kotlin.psi.KtEnumEntry
@@ -332,7 +331,7 @@ class ClassGenerator(
val substitutedDelegateTo = substituteDelegateToDescriptor(delegatedDescriptor, delegateToDescriptor) val substitutedDelegateTo = substituteDelegateToDescriptor(delegatedDescriptor, delegateToDescriptor)
val returnType = substitutedDelegateTo.returnType!! val returnType = substitutedDelegateTo.returnType!!
val delegateToSymbol = context.symbolTable.referenceFunction(delegateToDescriptor.original) val delegateToSymbol = context.symbolTable.referenceSimpleFunction(delegateToDescriptor.original)
val irCall = IrCallImpl( val irCall = IrCallImpl(
startOffset, endOffset, startOffset, endOffset,
@@ -29,7 +29,6 @@ import org.jetbrains.kotlin.ir.types.classifierOrFail
import org.jetbrains.kotlin.ir.types.classifierOrNull import org.jetbrains.kotlin.ir.types.classifierOrNull
import org.jetbrains.kotlin.ir.types.impl.originalKotlinType import org.jetbrains.kotlin.ir.types.impl.originalKotlinType
import org.jetbrains.kotlin.ir.types.makeNotNull import org.jetbrains.kotlin.ir.types.makeNotNull
import org.jetbrains.kotlin.ir.util.referenceFunction
import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.*
@@ -413,7 +412,7 @@ class OperatorExpressionGenerator(statementGenerator: StatementGenerator) : Stat
functionDescriptor: FunctionDescriptor, functionDescriptor: FunctionDescriptor,
receiver: IrExpression receiver: IrExpression
): IrExpression { ): IrExpression {
val originalSymbol = context.symbolTable.referenceFunction(functionDescriptor.original) val originalSymbol = context.symbolTable.referenceSimpleFunction(functionDescriptor.original)
return IrCallImpl( return IrCallImpl(
startOffset, startOffset,
endOffset, endOffset,
@@ -32,6 +32,7 @@ import org.jetbrains.kotlin.ir.expressions.*
import org.jetbrains.kotlin.ir.expressions.impl.* import org.jetbrains.kotlin.ir.expressions.impl.*
import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
import org.jetbrains.kotlin.ir.symbols.IrVariableSymbol import org.jetbrains.kotlin.ir.symbols.IrVariableSymbol
import org.jetbrains.kotlin.ir.util.* import org.jetbrains.kotlin.ir.util.*
import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.Name
@@ -197,18 +198,13 @@ class ReflectionReferencesGenerator(statementGenerator: StatementGenerator) : St
val irType = resolvedDescriptor.returnType!!.toIrType() val irType = resolvedDescriptor.returnType!!.toIrType()
val irCall = val irCall = when (adapteeSymbol) {
if (resolvedDescriptor is ConstructorDescriptor) is IrConstructorSymbol ->
IrConstructorCallImpl.fromSymbolDescriptor( IrConstructorCallImpl.fromSymbolDescriptor(startOffset, endOffset, irType, adapteeSymbol)
startOffset, endOffset, irType, is IrSimpleFunctionSymbol ->
adapteeSymbol as IrConstructorSymbol IrCallImpl(startOffset, endOffset, irType, adapteeSymbol, origin = null, superQualifierSymbol = null)
) else -> error("Unknown symbol kind $adapteeSymbol")
else }
IrCallImpl(
startOffset, endOffset, irType,
adapteeSymbol,
origin = null, superQualifierSymbol = null
)
val hasBoundDispatchReceiver = resolvedCall.dispatchReceiver != null && resolvedCall.dispatchReceiver !is TransientReceiver val hasBoundDispatchReceiver = resolvedCall.dispatchReceiver != null && resolvedCall.dispatchReceiver !is TransientReceiver
val hasBoundExtensionReceiver = resolvedCall.extensionReceiver != null && resolvedCall.extensionReceiver !is TransientReceiver val hasBoundExtensionReceiver = resolvedCall.extensionReceiver != null && resolvedCall.extensionReceiver !is TransientReceiver
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
import org.jetbrains.kotlin.ir.expressions.impl.* import org.jetbrains.kotlin.ir.expressions.impl.*
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.psi2ir.generators.GeneratorContext import org.jetbrains.kotlin.psi2ir.generators.GeneratorContext
@@ -126,9 +126,9 @@ class AccessorPropertyLValue(
endOffset: Int, endOffset: Int,
origin: IrStatementOrigin?, origin: IrStatementOrigin?,
type: IrType, type: IrType,
val getter: IrFunctionSymbol?, val getter: IrSimpleFunctionSymbol?,
val getterDescriptor: FunctionDescriptor?, val getterDescriptor: FunctionDescriptor?,
val setter: IrFunctionSymbol?, val setter: IrSimpleFunctionSymbol?,
val setterDescriptor: FunctionDescriptor?, val setterDescriptor: FunctionDescriptor?,
val typeArguments: List<IrType>?, val typeArguments: List<IrType>?,
callReceiver: CallReceiver, callReceiver: CallReceiver,
@@ -17,10 +17,12 @@
package org.jetbrains.kotlin.ir.expressions package org.jetbrains.kotlin.ir.expressions
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
abstract class IrCall( abstract class IrCall(
typeArgumentsCount: Int, typeArgumentsCount: Int,
valueArgumentsCount: Int, valueArgumentsCount: Int,
) : IrFunctionAccessExpression(typeArgumentsCount, valueArgumentsCount) { ) : IrFunctionAccessExpression(typeArgumentsCount, valueArgumentsCount) {
override abstract val symbol: IrSimpleFunctionSymbol
abstract val superQualifierSymbol: IrClassSymbol? abstract val superQualifierSymbol: IrClassSymbol?
} }
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
import org.jetbrains.kotlin.ir.expressions.typeParametersCount import org.jetbrains.kotlin.ir.expressions.typeParametersCount
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.render import org.jetbrains.kotlin.ir.util.render
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
@@ -31,7 +31,7 @@ class IrCallImpl(
override val startOffset: Int, override val startOffset: Int,
override val endOffset: Int, override val endOffset: Int,
override val type: IrType, override val type: IrType,
override val symbol: IrFunctionSymbol, override val symbol: IrSimpleFunctionSymbol,
typeArgumentsCount: Int, typeArgumentsCount: Int,
valueArgumentsCount: Int, valueArgumentsCount: Int,
override val origin: IrStatementOrigin? = null, override val origin: IrStatementOrigin? = null,
@@ -48,7 +48,7 @@ class IrCallImpl(
startOffset: Int, startOffset: Int,
endOffset: Int, endOffset: Int,
type: IrType, type: IrType,
symbol: IrFunctionSymbol, symbol: IrSimpleFunctionSymbol,
origin: IrStatementOrigin? = null, origin: IrStatementOrigin? = null,
superQualifierSymbol: IrClassSymbol? = null superQualifierSymbol: IrClassSymbol? = null
) : this( ) : this(
@@ -61,7 +61,7 @@ class IrCallImpl(
startOffset: Int, startOffset: Int,
endOffset: Int, endOffset: Int,
type: IrType, type: IrType,
symbol: IrFunctionSymbol, symbol: IrSimpleFunctionSymbol,
typeArgumentsCount: Int, typeArgumentsCount: Int,
origin: IrStatementOrigin? = null, origin: IrStatementOrigin? = null,
superQualifierSymbol: IrClassSymbol? = null superQualifierSymbol: IrClassSymbol? = null
@@ -519,7 +519,7 @@ open class DeepCopyIrTreeWithSymbols(
} }
private fun shallowCopyCall(expression: IrCall): IrCall { private fun shallowCopyCall(expression: IrCall): IrCall {
val newCallee = symbolRemapper.getReferencedFunction(expression.symbol) val newCallee = symbolRemapper.getReferencedSimpleFunction(expression.symbol)
return IrCallImpl( return IrCallImpl(
expression.startOffset, expression.endOffset, expression.startOffset, expression.endOffset,
expression.type.remapType(), expression.type.remapType(),
@@ -411,7 +411,7 @@ fun irConstructorCall(
fun irCall( fun irCall(
call: IrFunctionAccessExpression, call: IrFunctionAccessExpression,
newFunction: IrFunction, newFunction: IrSimpleFunction,
receiversAsArguments: Boolean = false, receiversAsArguments: Boolean = false,
argumentsAsReceivers: Boolean = false, argumentsAsReceivers: Boolean = false,
newSuperQualifierSymbol: IrClassSymbol? = null newSuperQualifierSymbol: IrClassSymbol? = null
@@ -426,7 +426,7 @@ fun irCall(
fun irCall( fun irCall(
call: IrFunctionAccessExpression, call: IrFunctionAccessExpression,
newSymbol: IrFunctionSymbol, newSymbol: IrSimpleFunctionSymbol,
receiversAsArguments: Boolean = false, receiversAsArguments: Boolean = false,
argumentsAsReceivers: Boolean = false, argumentsAsReceivers: Boolean = false,
newSuperQualifierSymbol: IrClassSymbol? = null newSuperQualifierSymbol: IrClassSymbol? = null
@@ -379,7 +379,7 @@ abstract class IrFileDeserializer(
} }
private fun deserializeCall(proto: ProtoCall, start: Int, end: Int, type: IrType): IrCall { private fun deserializeCall(proto: ProtoCall, start: Int, end: Int, type: IrType): IrCall {
val symbol = deserializeIrSymbolAndRemap(proto.symbol) as IrFunctionSymbol val symbol = deserializeIrSymbolAndRemap(proto.symbol) as IrSimpleFunctionSymbol
val superSymbol = if (proto.hasSuper()) { val superSymbol = if (proto.hasSuper()) {
deserializeIrSymbolAndRemap(proto.`super`) as IrClassSymbol deserializeIrSymbolAndRemap(proto.`super`) as IrClassSymbol
@@ -28,7 +28,6 @@ import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrFunctionReference import org.jetbrains.kotlin.ir.expressions.IrFunctionReference
import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrFunctionReferenceImpl import org.jetbrains.kotlin.ir.expressions.impl.IrFunctionReferenceImpl
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
import org.jetbrains.kotlin.ir.symbols.IrSymbol import org.jetbrains.kotlin.ir.symbols.IrSymbol
import org.jetbrains.kotlin.ir.types.* import org.jetbrains.kotlin.ir.types.*
@@ -51,7 +50,7 @@ class ParcelableIrTransformer(private val context: IrPluginContext, private val
private fun IrPluginContext.createIrBuilder(symbol: IrSymbol) = private fun IrPluginContext.createIrBuilder(symbol: IrSymbol) =
DeclarationIrBuilder(this, symbol, symbol.owner.startOffset, symbol.owner.endOffset) DeclarationIrBuilder(this, symbol, symbol.owner.startOffset, symbol.owner.endOffset)
private val symbolMap = mutableMapOf<IrFunctionSymbol, IrFunctionSymbol>() private val symbolMap = mutableMapOf<IrSimpleFunctionSymbol, IrSimpleFunctionSymbol>()
private val irFactory: IrFactory = IrFactoryImpl private val irFactory: IrFactory = IrFactoryImpl
@@ -91,7 +90,7 @@ class ParcelableIrTransformer(private val context: IrPluginContext, private val
override fun visitSimpleFunction(declaration: IrSimpleFunction): IrStatement { override fun visitSimpleFunction(declaration: IrSimpleFunction): IrStatement {
// Remap overridden symbols, otherwise the code might break in BridgeLowering // Remap overridden symbols, otherwise the code might break in BridgeLowering
declaration.overriddenSymbols = declaration.overriddenSymbols.map { symbol -> declaration.overriddenSymbols = declaration.overriddenSymbols.map { symbol ->
(symbolMap[symbol] ?: symbol) as IrSimpleFunctionSymbol symbolMap[symbol] ?: symbol
} }
return super.visitSimpleFunction(declaration) return super.visitSimpleFunction(declaration)
} }