diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt index a7ca7fbb5e2..5af0c5942d3 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/ConversionUtils.kt @@ -7,6 +7,7 @@ package org.jetbrains.kotlin.fir.backend import com.intellij.psi.PsiCompiledElement import org.jetbrains.kotlin.* +import org.jetbrains.kotlin.builtins.StandardNames.DATA_CLASS_COMPONENT_PREFIX import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.fir.* import org.jetbrains.kotlin.fir.builder.buildPackageDirective @@ -510,7 +511,7 @@ internal fun FirReference.statementOrigin(): IrStatementOrigin? { source?.elementType == KtNodeTypes.OPERATION_REFERENCE -> nameToOperationConventionOrigin[symbol.callableId.callableName] source?.kind is KtFakeSourceElementKind.DesugaredComponentFunctionCall -> - IrStatementOrigin.COMPONENT_N.withIndex(name.asString().removePrefix("component").toInt()) + IrStatementOrigin.COMPONENT_N.withIndex(name.asString().removePrefix(DATA_CLASS_COMPONENT_PREFIX).toInt()) else -> null } diff --git a/compiler/frontend.common/src/org/jetbrains/kotlin/resolve/DataClassResolver.kt b/compiler/frontend.common/src/org/jetbrains/kotlin/resolve/DataClassResolver.kt index d547a167486..98563f6753f 100644 --- a/compiler/frontend.common/src/org/jetbrains/kotlin/resolve/DataClassResolver.kt +++ b/compiler/frontend.common/src/org/jetbrains/kotlin/resolve/DataClassResolver.kt @@ -5,20 +5,19 @@ package org.jetbrains.kotlin.resolve +import org.jetbrains.kotlin.builtins.StandardNames.DATA_CLASS_COMPONENT_PREFIX import org.jetbrains.kotlin.builtins.StandardNames.DATA_CLASS_COPY import org.jetbrains.kotlin.name.Name object DataClassResolver { - private const val COMPONENT_FUNCTION_NAME_PREFIX = "component" + fun createComponentName(index: Int): Name = Name.identifier(DATA_CLASS_COMPONENT_PREFIX + index) - fun createComponentName(index: Int): Name = Name.identifier(COMPONENT_FUNCTION_NAME_PREFIX + index) - - fun getComponentIndex(componentName: String): Int = componentName.substring(COMPONENT_FUNCTION_NAME_PREFIX.length).toInt() + fun getComponentIndex(componentName: String): Int = componentName.substring(DATA_CLASS_COMPONENT_PREFIX.length).toInt() fun isComponentLike(name: Name): Boolean = isComponentLike(name.asString()) private fun isComponentLike(name: String): Boolean { - if (!name.startsWith(COMPONENT_FUNCTION_NAME_PREFIX)) return false + if (!name.startsWith(DATA_CLASS_COMPONENT_PREFIX)) return false try { getComponentIndex(name) diff --git a/core/compiler.common/src/org/jetbrains/kotlin/builtins/StandardNames.kt b/core/compiler.common/src/org/jetbrains/kotlin/builtins/StandardNames.kt index c15e6a11fc6..1ce86b31929 100644 --- a/core/compiler.common/src/org/jetbrains/kotlin/builtins/StandardNames.kt +++ b/core/compiler.common/src/org/jetbrains/kotlin/builtins/StandardNames.kt @@ -26,6 +26,8 @@ object StandardNames { @JvmField val DATA_CLASS_COPY = Name.identifier("copy") + @JvmField val DATA_CLASS_COMPONENT_PREFIX = "component" + @JvmField val HASHCODE_NAME = Name.identifier("hashCode") @JvmField val CHAR_CODE = Name.identifier("code")