JVM IR: Handle special names for overridden Enum.name/ordinal in MethodSignatureMapper

This commit is contained in:
Steven Schäfer
2019-12-27 12:12:07 +01:00
committed by Georgy Bronnikov
parent 6c166e744a
commit c027c0e659
@@ -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 <get-name> and <get-ordinal> 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)