IR: do not inherit IrFunctionReference from IrFunctionAccessExpression
To avoid the diamond hierarchy and to allow refactoring the IR element hierarchy from interfaces to classes, improving performance of visitors and transformers.
This commit is contained in:
@@ -14,7 +14,6 @@ import org.jetbrains.kotlin.backend.jvm.codegen.isInlineOnly
|
||||
import org.jetbrains.kotlin.backend.jvm.codegen.isJvmInterface
|
||||
import org.jetbrains.kotlin.backend.jvm.descriptors.JvmDeclarationFactory
|
||||
import org.jetbrains.kotlin.backend.jvm.lower.inlineclasses.unboxInlineClass
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.codegen.inline.coroutines.FOR_INLINE_SUFFIX
|
||||
import org.jetbrains.kotlin.config.JvmDefaultMode
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
@@ -281,14 +280,10 @@ fun createDelegatingCallWithPlaceholderTypeArguments(existingCall: IrCall, redir
|
||||
copyFromWithPlaceholderTypeArguments(existingCall, irBuiltIns)
|
||||
}
|
||||
|
||||
fun IrFunctionAccessExpression.copyFromWithPlaceholderTypeArguments(existingCall: IrFunctionAccessExpression, irBuiltIns: IrBuiltIns) {
|
||||
copyValueArgumentsFrom(
|
||||
existingCall,
|
||||
existingCall.symbol.owner,
|
||||
this.symbol.owner,
|
||||
receiversAsArguments = true,
|
||||
argumentsAsReceivers = false,
|
||||
)
|
||||
fun IrMemberAccessExpression<IrFunctionSymbol>.copyFromWithPlaceholderTypeArguments(
|
||||
existingCall: IrMemberAccessExpression<IrFunctionSymbol>, irBuiltIns: IrBuiltIns
|
||||
) {
|
||||
copyValueArgumentsFrom(existingCall, this.symbol.owner, receiversAsArguments = true, argumentsAsReceivers = false)
|
||||
var offset = 0
|
||||
existingCall.symbol.owner.parentAsClass.typeParameters.forEach { _ ->
|
||||
putTypeArgument(offset++, createPlaceholderAnyNType(irBuiltIns))
|
||||
|
||||
+6
-2
@@ -12,7 +12,10 @@ import org.jetbrains.kotlin.backend.common.lower.createIrBuilder
|
||||
import org.jetbrains.kotlin.backend.common.phaser.makeIrFilePhase
|
||||
import org.jetbrains.kotlin.backend.jvm.JvmBackendContext
|
||||
import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin
|
||||
import org.jetbrains.kotlin.backend.jvm.codegen.*
|
||||
import org.jetbrains.kotlin.backend.jvm.codegen.continuationParameter
|
||||
import org.jetbrains.kotlin.backend.jvm.codegen.hasContinuation
|
||||
import org.jetbrains.kotlin.backend.jvm.codegen.isInvokeSuspendOfContinuation
|
||||
import org.jetbrains.kotlin.backend.jvm.codegen.isReadOfCrossinline
|
||||
import org.jetbrains.kotlin.backend.jvm.ir.IrInlineReferenceLocator
|
||||
import org.jetbrains.kotlin.backend.jvm.ir.defaultValue
|
||||
import org.jetbrains.kotlin.backend.jvm.ir.isStaticInlineClassReplacement
|
||||
@@ -29,6 +32,7 @@ import org.jetbrains.kotlin.ir.builders.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.expressions.*
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.*
|
||||
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.impl.IrSimpleTypeImpl
|
||||
@@ -692,7 +696,7 @@ private fun IrFunction.continuationType(context: JvmBackendContext): IrType {
|
||||
context.ir.symbols.continuationClass.typeWith(returnType)
|
||||
}
|
||||
|
||||
private fun <T : IrFunctionAccessExpression> T.retargetToSuspendView(
|
||||
private fun <T : IrMemberAccessExpression<IrFunctionSymbol>> T.retargetToSuspendView(
|
||||
context: JvmBackendContext,
|
||||
caller: IrFunction?,
|
||||
copyWithTargetSymbol: T.(IrSimpleFunctionSymbol) -> T
|
||||
|
||||
@@ -23,7 +23,7 @@ interface IrCallableReference<S : IrSymbol> : IrMemberAccessExpression<S> {
|
||||
val referencedName: Name
|
||||
}
|
||||
|
||||
interface IrFunctionReference : IrCallableReference<IrFunctionSymbol>, IrFunctionAccessExpression {
|
||||
interface IrFunctionReference : IrCallableReference<IrFunctionSymbol> {
|
||||
val reflectionTarget: IrFunctionSymbol?
|
||||
}
|
||||
|
||||
|
||||
@@ -7,9 +7,9 @@ package org.jetbrains.kotlin.ir.util
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.impl.DeclarationDescriptorVisitorEmptyBodies
|
||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.IrStatement
|
||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl
|
||||
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
||||
@@ -499,18 +499,17 @@ fun irCall(
|
||||
}
|
||||
}
|
||||
|
||||
fun IrFunctionAccessExpression.copyTypeAndValueArgumentsFrom(
|
||||
src: IrFunctionAccessExpression,
|
||||
fun IrMemberAccessExpression<IrFunctionSymbol>.copyTypeAndValueArgumentsFrom(
|
||||
src: IrMemberAccessExpression<IrFunctionSymbol>,
|
||||
receiversAsArguments: Boolean = false,
|
||||
argumentsAsReceivers: Boolean = false
|
||||
) {
|
||||
copyTypeArgumentsFrom(src)
|
||||
copyValueArgumentsFrom(src, src.symbol.owner, symbol.owner, receiversAsArguments, argumentsAsReceivers)
|
||||
copyValueArgumentsFrom(src, symbol.owner, receiversAsArguments, argumentsAsReceivers)
|
||||
}
|
||||
|
||||
fun IrMemberAccessExpression<*>.copyValueArgumentsFrom(
|
||||
src: IrMemberAccessExpression<*>,
|
||||
srcFunction: IrFunction,
|
||||
fun IrMemberAccessExpression<IrFunctionSymbol>.copyValueArgumentsFrom(
|
||||
src: IrMemberAccessExpression<IrFunctionSymbol>,
|
||||
destFunction: IrFunction,
|
||||
receiversAsArguments: Boolean = false,
|
||||
argumentsAsReceivers: Boolean = false
|
||||
@@ -518,6 +517,8 @@ fun IrMemberAccessExpression<*>.copyValueArgumentsFrom(
|
||||
var destValueArgumentIndex = 0
|
||||
var srcValueArgumentIndex = 0
|
||||
|
||||
val srcFunction = src.symbol.owner
|
||||
|
||||
when {
|
||||
receiversAsArguments && srcFunction.dispatchReceiverParameter != null -> {
|
||||
putValueArgument(destValueArgumentIndex++, src.dispatchReceiver)
|
||||
|
||||
Reference in New Issue
Block a user