[IR] Remove usages of IrCallableReference after it was upgraded
This is, in all klib backends, after lowering pass started.
KT-72875
diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/AbstractValueUsageTransformer.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/AbstractValueUsageTransformer.kt
index 19da107..502f822 100644
--- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/AbstractValueUsageTransformer.kt
+++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/AbstractValueUsageTransformer.kt
@@ -72,18 +72,11 @@
protected open fun useAsVarargElement(element: IrExpression, expression: IrVararg): IrExpression = element
- override fun visitPropertyReference(expression: IrPropertyReference): IrExpression {
- TODO()
- }
override fun visitLocalDelegatedPropertyReference(expression: IrLocalDelegatedPropertyReference): IrExpression {
TODO()
}
- // override fun visitFunctionReference(expression: IrFunctionReference): IrExpression {
- // TODO()
- // }
-
override fun visitFunctionAccess(expression: IrFunctionAccessExpression): IrExpression {
expression.transformChildrenVoid(this)
diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/DelegatedPropertyOptimizationLowering.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/DelegatedPropertyOptimizationLowering.kt
index db4e582..e3dfffc 100644
--- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/DelegatedPropertyOptimizationLowering.kt
+++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/DelegatedPropertyOptimizationLowering.kt
@@ -83,12 +83,6 @@
return declaration
}
- override fun visitPropertyReference(expression: IrPropertyReference): IrExpression {
- super.visitPropertyReference(expression)
- if (expression.arguments.any { it != null }) return expression
- return delegatedProperties[expression.symbol]?.invoke(expression) ?: expression
- }
-
override fun visitLocalDelegatedPropertyReference(expression: IrLocalDelegatedPropertyReference): IrExpression {
super.visitLocalDelegatedPropertyReference(expression)
if (expression.arguments.any { it != null }) return expression
diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/IfNullExpressionsFusionLowering.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/IfNullExpressionsFusionLowering.kt
index e31c68f..5001bfa 100644
--- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/IfNullExpressionsFusionLowering.kt
+++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/IfNullExpressionsFusionLowering.kt
@@ -135,8 +135,6 @@
}
is IrConstructorCall,
is IrGetSingletonValue,
- is IrFunctionExpression,
- is IrCallableReference<*>,
is IrClassReference,
is IrGetClass ->
false
diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/inline/LocalClasses.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/inline/LocalClasses.kt
index 13b2889..0ca7535 100644
--- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/inline/LocalClasses.kt
+++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/inline/LocalClasses.kt
@@ -57,7 +57,6 @@
for (index in expression.arguments.indices) {
val argument = expression.arguments[index]
val inlineLambda = when (argument) {
- is IrFunctionExpression -> argument.function
is IrRichPropertyReference -> argument.getterFunction
is IrRichFunctionReference -> argument.invokeFunction
else -> null
@@ -84,10 +83,6 @@
localClasses.add(declaration)
}
- override fun visitFunctionExpression(expression: IrFunctionExpression) {
- expression.function.acceptChildrenVoid(this)
- }
-
override fun visitRichFunctionReference(expression: IrRichFunctionReference) {
expression.boundValues.forEach { it.acceptVoid(this) }
expression.invokeFunction.acceptChildrenVoid(this)
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/ir/IrBuilder.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/ir/IrBuilder.kt
index e69a71b..223f95c 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/ir/IrBuilder.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/ir/IrBuilder.kt
@@ -197,9 +197,6 @@
fun buildComposite(type: IrType, statements: List<IrStatement> = emptyList()) =
IrCompositeImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, type, JsStatementOrigins.SYNTHESIZED_STATEMENT, statements)
- fun buildFunctionExpression(type: IrType, function: IrSimpleFunction) =
- IrFunctionExpressionImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, type, function, JsStatementOrigins.SYNTHESIZED_STATEMENT)
-
fun buildVar(
type: IrType,
parent: IrDeclarationParent?,
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/JsStringConcatenationLowering.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/JsStringConcatenationLowering.kt
index b77fc85..0efce0f 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/JsStringConcatenationLowering.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/JsStringConcatenationLowering.kt
@@ -93,9 +93,6 @@
if (expression.symbol.isStringPlus)
return explicitlyConvertToStringIfNeeded()
- if ((expression.dispatchReceiver as? IrFunctionReference)?.symbol?.isStringPlus == true)
- return explicitlyConvertToStringIfNeeded()
-
return super.visitCall(expression)
}
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/PrivateMembersLowering.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/PrivateMembersLowering.kt
index bacb51d..089df81 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/PrivateMembersLowering.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/PrivateMembersLowering.kt
@@ -140,43 +140,6 @@
} ?: expression
}
- override fun visitFunctionReference(expression: IrFunctionReference): IrExpression {
- super.visitFunctionReference(expression)
-
- return expression.symbol.owner.correspondingStatic?.let {
- transformPrivateToStaticReference(expression) {
- IrFunctionReferenceImpl(
- expression.startOffset, expression.endOffset,
- expression.type,
- it.symbol, expression.typeArguments.size,
- expression.reflectionTarget, expression.origin
- )
- }
- } ?: expression
- }
-
- override fun visitPropertyReference(expression: IrPropertyReference): IrExpression {
- super.visitPropertyReference(expression)
-
- val staticGetter = expression.getter?.owner?.correspondingStatic
- val staticSetter = expression.setter?.owner?.correspondingStatic
-
- return if (staticGetter != null || staticSetter != null) {
- transformPrivateToStaticReference(expression) {
- IrPropertyReferenceImpl(
- expression.startOffset, expression.endOffset,
- expression.type,
- expression.symbol, // TODO remap property symbol based on remapped getter/setter?
- expression.typeArguments.size,
- expression.field,
- staticGetter?.symbol ?: expression.getter,
- staticSetter?.symbol ?: expression.setter,
- expression.origin
- )
- }
- } else expression
- }
-
private fun transformPrivateToStaticCall(expression: IrCall, staticTarget: IrSimpleFunction): IrCall {
val newExpression = IrCallImpl(
expression.startOffset, expression.endOffset,
@@ -192,19 +155,6 @@
return newExpression
}
-
- private fun transformPrivateToStaticReference(
- expression: IrCallableReference<*>,
- builder: () -> IrCallableReference<*>
- ): IrCallableReference<*> {
-
- val newExpression = builder()
-
- newExpression.arguments.assignFrom(expression.arguments)
- newExpression.copyTypeArgumentsFrom(expression)
-
- return newExpression
- }
}, null)
}
}
diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/coroutines/ReplaceSuspendIntrinsicLowering.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/coroutines/ReplaceSuspendIntrinsicLowering.kt
index 477cb56..7de442d 100644
--- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/coroutines/ReplaceSuspendIntrinsicLowering.kt
+++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/coroutines/ReplaceSuspendIntrinsicLowering.kt
@@ -37,25 +37,6 @@
override fun lower(irBody: IrBody, container: IrDeclaration) {
if (!context.compileSuspendAsJsGenerator) return
irBody.transformChildrenVoid(object : IrElementTransformerVoid() {
- override fun visitCallableReference(expression: IrCallableReference<*>): IrExpression {
- if (expression.symbol !is IrSimpleFunctionSymbol) return super.visitCallableReference(expression)
-
- @Suppress("UNCHECKED_CAST")
- val reference = expression as IrCallableReference<IrSimpleFunctionSymbol>
-
- when (val symbol = reference.symbol) {
- in context.intrinsics.createCoroutineUnintercepted -> {
- reference.symbol = valueParamSizeToItsCreateCoroutineUnintercepted.getValue(symbol.regularParamCount)
- }
- in context.intrinsics.startCoroutineUninterceptedOrReturnNonGeneratorVersion -> {
- reference.symbol =
- valueParamSizeToItsStartCoroutineUninterceptedOrReturnGeneratorVersion.getValue(symbol.regularParamCount)
- }
- }
-
- return super.visitCallableReference(reference)
- }
-
override fun visitCall(expression: IrCall): IrExpression {
when (val symbol = expression.symbol) {
in context.intrinsics.createCoroutineUnintercepted -> {
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/builders/ExpressionHelpers.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/builders/ExpressionHelpers.kt
index 232b6b3..1faaa52 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/builders/ExpressionHelpers.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/builders/ExpressionHelpers.kt
@@ -373,16 +373,6 @@
fun IrBuilder.irRawFunctionReference(type: IrType, symbol: IrFunctionSymbol) =
IrRawFunctionReferenceImpl(startOffset, endOffset, type, symbol)
-fun IrBuilder.irFunctionReference(type: IrType, symbol: IrFunctionSymbol, reflectionTargetSymbol: IrFunctionSymbol? = symbol) =
- IrFunctionReferenceImpl(
- startOffset,
- endOffset,
- type,
- symbol,
- symbol.owner.typeParameters.size,
- reflectionTargetSymbol,
- )
-
fun IrBuilder.irTry(type: IrType, tryResult: IrExpression, catches: List<IrCatch>, finallyExpression: IrExpression?) =
IrTryImpl(startOffset, endOffset, type, tryResult, catches, finallyExpression)
diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrExpressions.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrExpressions.kt
index 6f9e2d8..fa56b0b 100644
--- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrExpressions.kt
+++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrExpressions.kt
@@ -17,12 +17,6 @@
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.render
-val IrFunctionReference.isWithReflection: Boolean
- get() = reflectionTarget != null
-
-val IrFunctionReference.isAdapterWithReflection: Boolean
- get() = reflectionTarget != null && reflectionTarget != symbol
-
var IrDynamicOperatorExpression.left: IrExpression
get() = receiver
set(value) {
diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/common/AbstractValueUsageTransformer.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/common/AbstractValueUsageTransformer.kt
index 84b16111..0bb1b51 100644
--- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/common/AbstractValueUsageTransformer.kt
+++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/common/AbstractValueUsageTransformer.kt
@@ -75,15 +75,7 @@
protected open fun IrExpression.useAsResult(enclosing: IrExpression): IrExpression =
this.useAs(enclosing.type)
- override fun visitPropertyReference(expression: IrPropertyReference): IrExpression {
- TODO()
- }
-
- override fun visitLocalDelegatedPropertyReference(expression: IrLocalDelegatedPropertyReference): IrExpression {
- TODO()
- }
-
- override fun visitFunctionReference(expression: IrFunctionReference): IrExpression {
+ override fun visitRichCallableReference(expression: IrRichCallableReference<*>): IrExpression {
TODO()
}
diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/Autoboxing.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/Autoboxing.kt
index edf7cd5..c6f1e64 100644
--- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/Autoboxing.kt
+++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/Autoboxing.kt
@@ -235,12 +235,6 @@
}
}
- override fun visitFunctionReference(expression: IrFunctionReference): IrExpression {
- expression.transformChildrenVoid()
- assert(expression.getArgumentsWithIr().isEmpty())
- return expression
- }
-
override fun visitCall(expression: IrCall): IrExpression {
return when (expression.symbol) {
symbols.reinterpret -> {
diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/VolatileFieldsLowering.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/VolatileFieldsLowering.kt
index 64994f2..497562c 100644
--- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/VolatileFieldsLowering.kt
+++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/VolatileFieldsLowering.kt
@@ -214,7 +214,6 @@
private tailrec fun getConstPropertyReference(expression: IrExpression?, expectedReturn: IrReturnableBlockSymbol?) : IrRichPropertyReference? {
return when {
expression == null -> null
- expectedReturn == null && expression is IrPropertyReference -> shouldNotBeCalled()
expectedReturn == null && expression is IrRichPropertyReference -> expression
expectedReturn == null && expression is IrReturnableBlock -> getConstPropertyReference(expression.singleExpressionOrNull, expression.symbol)
expression is IrReturn && expression.returnTargetSymbol == expectedReturn -> getConstPropertyReference(expression.value, null)