From 4f87c094512cedf0c07c300136b2ba45fa31c4ac Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Wed, 1 Jul 2020 13:16:17 +0200 Subject: [PATCH] IR: add type parameter to IrMemberAccessExpression and some subclasses https://github.com/JetBrains/kotlin/commit/d4605f581657fd01925bfb1d75bd09a0323f3e84 (cherry picked from commit 45893f45601c13d6af2dffae01cf9630f5da374a) --- .../org/jetbrains/kotlin/backend/konan/cgen/CBridgeGen.kt | 2 +- .../kotlin/backend/konan/cgen/CBridgeGenUtils.kt | 2 +- .../jetbrains/kotlin/backend/konan/lower/Autoboxing.kt | 2 +- .../backend/konan/lower/EnumConstructorsLowering.kt | 2 +- .../backend/konan/lower/NativeSuspendFunctionLowering.kt | 8 ++++---- .../kotlin/backend/konan/lower/ReflectionSupport.kt | 2 +- .../kotlin/backend/konan/optimizations/DFGBuilder.kt | 4 ++-- .../src/org/jetbrains/kotlin/ir/util/IrUtils2.kt | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/cgen/CBridgeGen.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/cgen/CBridgeGen.kt index 588293a76c7..f41b3cbf8d9 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/cgen/CBridgeGen.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/cgen/CBridgeGen.kt @@ -101,7 +101,7 @@ private fun KotlinToCCallBuilder.addArgument( if (!variadic) cFunctionBuilder.addParameter(cArgument.type) } -private fun KotlinToCCallBuilder.buildKotlinBridgeCall(transformCall: (IrMemberAccessExpression) -> IrExpression = { it }): IrExpression = +private fun KotlinToCCallBuilder.buildKotlinBridgeCall(transformCall: (IrMemberAccessExpression<*>) -> IrExpression = { it }): IrExpression = bridgeCallBuilder.build( bridgeBuilder.buildKotlinBridge().also { this.stubs.addKotlin(it) diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/cgen/CBridgeGenUtils.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/cgen/CBridgeGenUtils.kt index cb119be41cb..f26378e8e32 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/cgen/CBridgeGenUtils.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/cgen/CBridgeGenUtils.kt @@ -186,7 +186,7 @@ internal class KotlinCallBuilder(private val irBuilder: IrBuilderWithScope, priv fun build( function: IrFunction, - transformCall: (IrMemberAccessExpression) -> IrExpression = { it } + transformCall: (IrMemberAccessExpression<*>) -> IrExpression = { it } ): IrExpression { val arguments = this.arguments.toMutableList() diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/Autoboxing.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/Autoboxing.kt index fde272a2f7c..b837cbaec9b 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/Autoboxing.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/Autoboxing.kt @@ -424,7 +424,7 @@ private class InlineClassTransformer(private val context: Context) : IrBuildingT } private fun IrBuilderWithScope.lowerConstructorCallToValue( - expression: IrMemberAccessExpression, + expression: IrMemberAccessExpression<*>, callee: IrConstructor ): IrExpression = if (callee.isPrimary) { expression.getValueArgument(0)!! diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/EnumConstructorsLowering.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/EnumConstructorsLowering.kt index 36240c00094..b6bc80f4e9b 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/EnumConstructorsLowering.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/EnumConstructorsLowering.kt @@ -266,7 +266,7 @@ internal class EnumConstructorsLowering(val context: Context) : ClassLoweringPas throw AssertionError("Unexpected delegating constructor call within enum entry: $enumEntry") } - abstract fun createConstructorCall(startOffset: Int, endOffset: Int, loweredConstructor: IrConstructorSymbol): IrMemberAccessExpression + abstract fun createConstructorCall(startOffset: Int, endOffset: Int, loweredConstructor: IrConstructorSymbol): IrMemberAccessExpression<*> } private inner class InEnumEntryClassConstructor(enumEntry: IrEnumEntry) : InEnumEntry(enumEntry) { diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/NativeSuspendFunctionLowering.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/NativeSuspendFunctionLowering.kt index caa56f38275..be7be513cc8 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/NativeSuspendFunctionLowering.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/NativeSuspendFunctionLowering.kt @@ -270,7 +270,7 @@ internal class NativeSuspendFunctionsLowering(ctx: Context): AbstractSuspendFunc return sliceExpression(expression) } - override fun visitMemberAccess(expression: IrMemberAccessExpression): IrExpression { + override fun visitMemberAccess(expression: IrMemberAccessExpression<*>): IrExpression { expression.transformChildrenVoid(this) return sliceExpression(expression) @@ -281,7 +281,7 @@ internal class NativeSuspendFunctionsLowering(ctx: Context): AbstractSuspendFunc irBuilder.run { val children = when (expression) { is IrSetField -> listOf(expression.receiver, expression.value) - is IrMemberAccessExpression -> ( + is IrMemberAccessExpression<*> -> ( listOf(expression.dispatchReceiver, expression.extensionReceiver) + (0 until expression.valueArgumentsCount).map { expression.getValueArgument(it) } ) @@ -365,7 +365,7 @@ internal class NativeSuspendFunctionsLowering(ctx: Context): AbstractSuspendFunc expression.receiver = newChildren[0] expression.value = newChildren[1]!! } - is IrMemberAccessExpression -> { + is IrMemberAccessExpression<*> -> { expression.dispatchReceiver = newChildren[0] expression.extensionReceiver = newChildren[1] newChildren.drop(2).forEachIndexed { index, newChild -> @@ -549,7 +549,7 @@ internal class NativeSuspendFunctionsLowering(ctx: Context): AbstractSuspendFunc } } - fun IrBlockBodyBuilder.irSuccess(value: IrExpression): IrMemberAccessExpression { + fun IrBlockBodyBuilder.irSuccess(value: IrExpression): IrMemberAccessExpression<*> { val createResult = symbols.kotlinResult.owner.constructors.single { it.isPrimary } return irCall(createResult).apply { putValueArgument(0, value) diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/ReflectionSupport.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/ReflectionSupport.kt index 8370f4caf13..b4e819ad9ed 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/ReflectionSupport.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/ReflectionSupport.kt @@ -67,7 +67,7 @@ internal class KTypeGenerator( private fun IrBuilderWithScope.irKTypeProjectionsList( irTypeArguments: List - ): IrMemberAccessExpression { + ): IrMemberAccessExpression<*> { val kTypeProjectionType = symbols.kTypeProjection.typeWithoutArguments return if (irTypeArguments.isEmpty()) { diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/optimizations/DFGBuilder.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/optimizations/DFGBuilder.kt index f9ef8ebf56a..d1deb8251f5 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/optimizations/DFGBuilder.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/optimizations/DFGBuilder.kt @@ -116,7 +116,7 @@ private class ExpressionValuesExtractor(val context: Context, is IrWhen -> expression.branches.forEach { forEachValue(it.result, block) } - is IrMemberAccessExpression -> block(expression) + is IrMemberAccessExpression<*> -> block(expression) is IrGetValue -> block(expression) @@ -319,7 +319,7 @@ internal class ModuleDFGBuilder(val context: Context, val irModule: IrModuleFrag override fun visitExpression(expression: IrExpression) { when (expression) { - is IrMemberAccessExpression, + is IrMemberAccessExpression<*>, is IrGetField, is IrGetObjectValue, is IrVararg, diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/ir/util/IrUtils2.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/ir/util/IrUtils2.kt index 66ad3997e8d..a180d18d5be 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/ir/util/IrUtils2.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/ir/util/IrUtils2.kt @@ -293,7 +293,7 @@ fun IrBuilderWithScope.irCatch(type: IrType) = * Binds the arguments explicitly represented in the IR to the parameters of the accessed function. * The arguments are to be evaluated in the same order as they appear in the resulting list. */ -fun IrMemberAccessExpression.getArgumentsWithIr(): List> { +fun IrMemberAccessExpression<*>.getArgumentsWithIr(): List> { val res = mutableListOf>() val irFunction = when (this) { is IrFunctionAccessExpression -> this.symbol.owner