diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/DataClassMembersGenerator.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/DataClassMembersGenerator.kt index 1cd31fcf5f2..820ee30493e 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/DataClassMembersGenerator.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/DataClassMembersGenerator.kt @@ -7,9 +7,7 @@ package org.jetbrains.kotlin.fir.backend.generators import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.fir.COPY_NAME -import org.jetbrains.kotlin.fir.EQUALS_NAME import org.jetbrains.kotlin.fir.HASHCODE_NAME -import org.jetbrains.kotlin.fir.TOSTRING_NAME import org.jetbrains.kotlin.fir.backend.Fir2IrComponents import org.jetbrains.kotlin.fir.backend.FirMetadataSource import org.jetbrains.kotlin.fir.backend.declareThisReceiverParameter @@ -45,6 +43,8 @@ import org.jetbrains.kotlin.ir.types.classifierOrNull import org.jetbrains.kotlin.ir.util.* import org.jetbrains.kotlin.ir.util.DataClassMembersGenerator import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.util.OperatorNameConventions.EQUALS +import org.jetbrains.kotlin.util.OperatorNameConventions.TO_STRING /** * A generator that generates synthetic members of data class as well as part of inline class. @@ -170,9 +170,9 @@ class DataClassMembersGenerator(val components: Fir2IrComponents) { returnTypeRef.toIrType(components.typeConverter) == components.irBuiltIns.stringType private val FirSimpleFunction.matchesDataClassSyntheticMemberSignatures: Boolean - get() = (this.name == EQUALS_NAME && matchesEqualsSignature) || + get() = (this.name == EQUALS && matchesEqualsSignature) || (this.name == HASHCODE_NAME && matchesHashCodeSignature) || - (this.name == TOSTRING_NAME && matchesToStringSignature) + (this.name == TO_STRING && matchesToStringSignature) fun generate(klass: FirClass<*>): List { val propertyParametersCount = irClass.primaryConstructor?.explicitParameters?.size ?: 0 @@ -194,7 +194,7 @@ class DataClassMembersGenerator(val components: Fir2IrComponents) { val contributedFunctionsInSupertypes = @OptIn(ExperimentalStdlibApi::class) buildMap { - for (name in listOf(EQUALS_NAME, HASHCODE_NAME, TOSTRING_NAME)) { + for (name in listOf(EQUALS, HASHCODE_NAME, TO_STRING)) { klass.unsubstitutedScope( components.session, components.scopeSession, @@ -213,12 +213,12 @@ class DataClassMembersGenerator(val components: Fir2IrComponents) { return declaration.modality != Modality.FINAL } - if (!contributedFunctionsInThisType.contains(EQUALS_NAME) && - isOverridableDeclaration(EQUALS_NAME) + if (!contributedFunctionsInThisType.contains(EQUALS) && + isOverridableDeclaration(EQUALS) ) { - result.add(contributedFunctionsInSupertypes.getValue(EQUALS_NAME)) + result.add(contributedFunctionsInSupertypes.getValue(EQUALS)) val equalsFunction = createSyntheticIrFunction( - EQUALS_NAME, + EQUALS, components.irBuiltIns.booleanType, otherParameterNeeded = true ) @@ -238,12 +238,12 @@ class DataClassMembersGenerator(val components: Fir2IrComponents) { irClass.declarations.add(hashCodeFunction) } - if (!contributedFunctionsInThisType.contains(TOSTRING_NAME) && - isOverridableDeclaration(TOSTRING_NAME) + if (!contributedFunctionsInThisType.contains(TO_STRING) && + isOverridableDeclaration(TO_STRING) ) { - result.add(contributedFunctionsInSupertypes.getValue(TOSTRING_NAME)) + result.add(contributedFunctionsInSupertypes.getValue(TO_STRING)) val toStringFunction = createSyntheticIrFunction( - TOSTRING_NAME, + TO_STRING, components.irBuiltIns.stringType, ) irDataClassMembersGenerator.generateToStringMethod(toStringFunction, properties) diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/DefaultNames.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/DefaultNames.kt index e345ee83951..0789bbf6ac6 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/DefaultNames.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/DefaultNames.kt @@ -13,6 +13,4 @@ val CONSTRUCTOR_NAME = Name.special("") // Data class synthetic members val COPY_NAME = Name.identifier("copy") -val EQUALS_NAME = Name.identifier("equals") val HASHCODE_NAME = Name.identifier("hashCode") -val TOSTRING_NAME = Name.identifier("toString")