[IR] Don't call copyAttributes in UpgradeCallableReferences
copyAttributes would assign attributeOwnerId to the old reference
element, which means both new and old reference element classes were
reachable in IR tree. That is not quite expected.
There are also no IR attributes defined for IrCallableReference
(especially so early in the pipeline), and if there were, they would
likely need some remapping logic, as the element classes are quite
different.
diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/UpgradeCallableReferences.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/UpgradeCallableReferences.kt
index 2016135..f8c72e5 100644
--- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/UpgradeCallableReferences.kt
+++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/UpgradeCallableReferences.kt
@@ -98,9 +98,7 @@
invokeFunction = expression.function,
origin = expression.origin,
isRestrictedSuspension = isRestrictedSuspension,
- ).apply {
- copyAttributes(expression)
- }
+ )
}
override fun visitElement(element: IrElement, data: IrDeclarationParent): IrElement {
@@ -183,7 +181,6 @@
hasVarargConversion = reflectionTarget is IrSimpleFunctionSymbol && hasVarargConversion(function, reflectionTarget.owner),
isRestrictedSuspension = isRestrictedSuspension,
).apply {
- copyAttributes(reference)
boundValues.addAll(reference.arguments.filterNotNull())
}.let {
if (samType != null) {
@@ -229,7 +226,6 @@
origin = expression.origin,
isRestrictedSuspension = expression.symbol.owner.isRestrictedSuspensionFunction(),
).apply {
- copyAttributes(expression)
boundValues += arguments.map { it.second }
}
}
@@ -265,7 +261,6 @@
setterFunction = setterFun,
origin = expression.origin,
).apply {
- copyAttributes(expression)
boundValues += arguments.map { it.second }
}
}
diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt
index 85e8f77..7d2c703 100644
--- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt
+++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt
@@ -816,7 +816,7 @@
val file = run {
val originalFunction = when (val original = declaration.attributeOwnerId) {
- is IrFunctionExpression -> original.function
+ is IrRichFunctionReference -> original.invokeFunction
is IrFunction -> original
else -> return@run null
}