From c027c0e659a91e109df3d10042d7cc581ecab90f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steven=20Sch=C3=A4fer?= Date: Fri, 27 Dec 2019 12:12:07 +0100 Subject: [PATCH] JVM IR: Handle special names for overridden Enum.name/ordinal in MethodSignatureMapper --- .../backend/jvm/codegen/MethodSignatureMapper.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/MethodSignatureMapper.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/MethodSignatureMapper.kt index 571882dd22c..8ed785a893d 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/MethodSignatureMapper.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/MethodSignatureMapper.kt @@ -75,7 +75,15 @@ class MethodSignatureMapper(private val context: JvmBackendContext) { val property = (function as? IrSimpleFunction)?.correspondingPropertySymbol?.owner if (property != null && function.name.isSpecial) { val propertyName = property.name.asString() - if (property.parent.let { it is IrClass && it.isAnnotationClass }) return propertyName + val propertyParent = property.parentAsClass + if (propertyParent.isAnnotationClass) + return propertyName + + // The enum property getters and have special names which also + // apply to their fake overrides. Unfortunately, getJvmMethodNameIfSpecial does not handle + // fake overrides, so we need a special case here. + if ((propertyParent.isEnumClass || propertyParent.isEnumEntry) && (propertyName == "name" || propertyName == "ordinal")) + return propertyName val accessorName = if (function.isPropertyGetter) JvmAbi.getterName(propertyName) else JvmAbi.setterName(propertyName) return mangleMemberNameIfRequired(accessorName, function)