JVM IR: do not mangle property accessors of unsigned types in annotations

Before this change, we incorrectly mangled the names of annotation
methods (e.g. `getI-pVg5ArA` instead of `i`) because the isSpecial
condition was false.
This commit is contained in:
Alexander Udalov
2020-08-28 21:47:10 +02:00
parent 1e360d9c91
commit a639915a34
5 changed files with 32 additions and 3 deletions
@@ -81,7 +81,7 @@ class MethodSignatureMapper(private val context: JvmBackendContext) {
}
val property = (function as? IrSimpleFunction)?.correspondingPropertySymbol?.owner
if (property != null && function.name.isSpecial) {
if (property != null) {
val propertyName = property.name.asString()
val propertyParent = property.parentAsClass
if (propertyParent.isAnnotationClass)
@@ -93,8 +93,10 @@ class MethodSignatureMapper(private val context: JvmBackendContext) {
if ((propertyParent.isEnumClass || propertyParent.isEnumEntry) && (propertyName == "name" || propertyName == "ordinal"))
return propertyName
val accessorName = if (function.isGetter) JvmAbi.getterName(propertyName) else JvmAbi.setterName(propertyName)
return mangleMemberNameIfRequired(accessorName, function)
if (function.name.isSpecial) {
val accessorName = if (function.isGetter) JvmAbi.getterName(propertyName) else JvmAbi.setterName(propertyName)
return mangleMemberNameIfRequired(accessorName, function)
}
}
return mangleMemberNameIfRequired(function.name.asString(), function)
@@ -0,0 +1,8 @@
// WITH_RUNTIME
annotation class Anno(
val b: UByte,
val i: UInt,
val l: ULong,
val s: UShort,
)
@@ -0,0 +1,9 @@
@java.lang.annotation.Retention
@kotlin.Metadata
public annotation class Anno {
// source: 'unsignedTypes.kt'
public abstract method b(): byte
public abstract method i(): int
public abstract method l(): long
public abstract method s(): short
}
@@ -230,6 +230,11 @@ public class BytecodeListingTestGenerated extends AbstractBytecodeListingTest {
public void testOnReceiver() throws Exception {
runTest("compiler/testData/codegen/bytecodeListing/annotations/onReceiver.kt");
}
@TestMetadata("unsignedTypes.kt")
public void testUnsignedTypes() throws Exception {
runTest("compiler/testData/codegen/bytecodeListing/annotations/unsignedTypes.kt");
}
}
@TestMetadata("compiler/testData/codegen/bytecodeListing/collectionStubs")
@@ -230,6 +230,11 @@ public class IrBytecodeListingTestGenerated extends AbstractIrBytecodeListingTes
public void testOnReceiver() throws Exception {
runTest("compiler/testData/codegen/bytecodeListing/annotations/onReceiver.kt");
}
@TestMetadata("unsignedTypes.kt")
public void testUnsignedTypes() throws Exception {
runTest("compiler/testData/codegen/bytecodeListing/annotations/unsignedTypes.kt");
}
}
@TestMetadata("compiler/testData/codegen/bytecodeListing/collectionStubs")