JVM IR: fix names of $annotations methods with inline classes in signature
#KT-40385 Fixed
This commit is contained in:
+13
-3
@@ -12,6 +12,8 @@ import org.jetbrains.kotlin.backend.common.lower.createIrBuilder
|
|||||||
import org.jetbrains.kotlin.backend.jvm.JvmBackendContext
|
import org.jetbrains.kotlin.backend.jvm.JvmBackendContext
|
||||||
import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin
|
import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin
|
||||||
import org.jetbrains.kotlin.backend.jvm.ir.needsAccessor
|
import org.jetbrains.kotlin.backend.jvm.ir.needsAccessor
|
||||||
|
import org.jetbrains.kotlin.backend.jvm.lower.inlineclasses.hasMangledReturnType
|
||||||
|
import org.jetbrains.kotlin.backend.jvm.lower.inlineclasses.requiresMangling
|
||||||
import org.jetbrains.kotlin.config.LanguageFeature
|
import org.jetbrains.kotlin.config.LanguageFeature
|
||||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||||
import org.jetbrains.kotlin.descriptors.Modality
|
import org.jetbrains.kotlin.descriptors.Modality
|
||||||
@@ -143,9 +145,17 @@ class JvmPropertiesLowering(private val backendContext: JvmBackendContext) : IrE
|
|||||||
private fun computeSyntheticMethodName(property: IrProperty): String {
|
private fun computeSyntheticMethodName(property: IrProperty): String {
|
||||||
val baseName =
|
val baseName =
|
||||||
if (backendContext.state.languageVersionSettings.supportsFeature(LanguageFeature.UseGetterNameForPropertyAnnotationsMethodOnJvm)) {
|
if (backendContext.state.languageVersionSettings.supportsFeature(LanguageFeature.UseGetterNameForPropertyAnnotationsMethodOnJvm)) {
|
||||||
property.getter?.let { getter ->
|
val getter = property.getter
|
||||||
backendContext.methodSignatureMapper.mapFunctionName(getter)
|
if (getter != null) {
|
||||||
} ?: JvmAbi.getterName(property.name.asString())
|
val needsMangling =
|
||||||
|
getter.extensionReceiverParameter?.type?.requiresMangling == true ||
|
||||||
|
(backendContext.state.functionsWithInlineClassReturnTypesMangled && getter.hasMangledReturnType)
|
||||||
|
|
||||||
|
backendContext.methodSignatureMapper.mapFunctionName(
|
||||||
|
if (needsMangling) backendContext.inlineClassReplacements.getReplacementFunction(getter) ?: getter
|
||||||
|
else getter
|
||||||
|
)
|
||||||
|
} else JvmAbi.getterName(property.name.asString())
|
||||||
} else {
|
} else {
|
||||||
property.name.asString()
|
property.name.asString()
|
||||||
}
|
}
|
||||||
|
|||||||
+20
@@ -0,0 +1,20 @@
|
|||||||
|
inline class Z(val x: Int) {
|
||||||
|
@Anno
|
||||||
|
val member: Int get() = x
|
||||||
|
}
|
||||||
|
|
||||||
|
annotation class Anno
|
||||||
|
|
||||||
|
@Anno
|
||||||
|
val Z.topLevel: Int get() = 0
|
||||||
|
|
||||||
|
@Anno
|
||||||
|
val returnType: Z get() = Z(0)
|
||||||
|
|
||||||
|
class C {
|
||||||
|
@Anno
|
||||||
|
val Z.memberExtension: Int get() = 0
|
||||||
|
|
||||||
|
@Anno
|
||||||
|
val returnType: Z get() = Z(0)
|
||||||
|
}
|
||||||
+44
@@ -0,0 +1,44 @@
|
|||||||
|
@java.lang.annotation.Retention
|
||||||
|
@kotlin.Metadata
|
||||||
|
public annotation class Anno {
|
||||||
|
// source: 'annotatedPropertyWithInlineClassTypeInSignature.kt'
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
public final class AnnotatedPropertyWithInlineClassTypeInSignatureKt {
|
||||||
|
// source: 'annotatedPropertyWithInlineClassTypeInSignature.kt'
|
||||||
|
public synthetic deprecated static @Anno method getReturnType$annotations(): void
|
||||||
|
public final static method getReturnType(): int
|
||||||
|
public synthetic deprecated static @Anno method getTopLevel-IQRRRT4$annotations(p0: int): void
|
||||||
|
public final static method getTopLevel-IQRRRT4(p0: int): int
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
public final class C {
|
||||||
|
// source: 'annotatedPropertyWithInlineClassTypeInSignature.kt'
|
||||||
|
public method <init>(): void
|
||||||
|
public synthetic deprecated static @Anno method getMemberExtension-IQRRRT4$annotations(p0: int): void
|
||||||
|
public final method getMemberExtension-IQRRRT4(p0: int): int
|
||||||
|
public synthetic deprecated static @Anno method getReturnType-a_XrcN0$annotations(): void
|
||||||
|
public final method getReturnType-a_XrcN0(): int
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
public final class Z {
|
||||||
|
// source: 'annotatedPropertyWithInlineClassTypeInSignature.kt'
|
||||||
|
private final field x: int
|
||||||
|
private synthetic method <init>(p0: int): void
|
||||||
|
public synthetic final static method box-impl(p0: int): Z
|
||||||
|
public static method constructor-impl(p0: int): int
|
||||||
|
public method equals(p0: java.lang.Object): boolean
|
||||||
|
public static method equals-impl(p0: int, p1: java.lang.Object): boolean
|
||||||
|
public final static method equals-impl0(p0: int, p1: int): boolean
|
||||||
|
public synthetic deprecated static @Anno method getMember$annotations(): void
|
||||||
|
public final static method getMember-impl(p0: int): int
|
||||||
|
public final method getX(): int
|
||||||
|
public method hashCode(): int
|
||||||
|
public static method hashCode-impl(p0: int): int
|
||||||
|
public method toString(): java.lang.String
|
||||||
|
public static method toString-impl(p0: int): java.lang.String
|
||||||
|
public synthetic final method unbox-impl(): int
|
||||||
|
}
|
||||||
+5
@@ -807,6 +807,11 @@ public class BytecodeListingTestGenerated extends AbstractBytecodeListingTest {
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeListing/inlineClasses"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeListing/inlineClasses"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("annotatedPropertyWithInlineClassTypeInSignature.kt")
|
||||||
|
public void testAnnotatedPropertyWithInlineClassTypeInSignature() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/annotatedPropertyWithInlineClassTypeInSignature.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("annotationsOnHiddenConstructor.kt")
|
@TestMetadata("annotationsOnHiddenConstructor.kt")
|
||||||
public void testAnnotationsOnHiddenConstructor() throws Exception {
|
public void testAnnotationsOnHiddenConstructor() throws Exception {
|
||||||
runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/annotationsOnHiddenConstructor.kt");
|
runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/annotationsOnHiddenConstructor.kt");
|
||||||
|
|||||||
+5
@@ -777,6 +777,11 @@ public class IrBytecodeListingTestGenerated extends AbstractIrBytecodeListingTes
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeListing/inlineClasses"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeListing/inlineClasses"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("annotatedPropertyWithInlineClassTypeInSignature.kt")
|
||||||
|
public void testAnnotatedPropertyWithInlineClassTypeInSignature() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/annotatedPropertyWithInlineClassTypeInSignature.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("annotationsOnHiddenConstructor.kt")
|
@TestMetadata("annotationsOnHiddenConstructor.kt")
|
||||||
public void testAnnotationsOnHiddenConstructor() throws Exception {
|
public void testAnnotationsOnHiddenConstructor() throws Exception {
|
||||||
runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/annotationsOnHiddenConstructor.kt");
|
runTest("compiler/testData/codegen/bytecodeListing/inlineClasses/annotationsOnHiddenConstructor.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user