JVM IR: fix names of $annotations methods for internal properties
#KT-40384 Fixed
This commit is contained in:
+3
-5
@@ -28,7 +28,6 @@ import org.jetbrains.kotlin.ir.expressions.IrFunctionReference
|
|||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrBlockBodyImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrBlockBodyImpl
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrSetFieldImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrSetFieldImpl
|
||||||
import org.jetbrains.kotlin.ir.util.*
|
import org.jetbrains.kotlin.ir.util.*
|
||||||
import org.jetbrains.kotlin.load.java.JvmAbi
|
|
||||||
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
|
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
|
||||||
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader
|
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader
|
||||||
import org.jetbrains.kotlin.metadata.jvm.serialization.JvmStringTable
|
import org.jetbrains.kotlin.metadata.jvm.serialization.JvmStringTable
|
||||||
@@ -366,10 +365,9 @@ class ClassCodegen private constructor(
|
|||||||
|
|
||||||
when (val metadata = method.metadata) {
|
when (val metadata = method.metadata) {
|
||||||
is MetadataSource.Property -> {
|
is MetadataSource.Property -> {
|
||||||
// We can't check for JvmLoweredDeclarationOrigin.SYNTHETIC_METHOD_FOR_PROPERTY_ANNOTATIONS because for interface methods
|
assert(method.isSyntheticMethodForProperty) {
|
||||||
// moved to DefaultImpls, origin is changed to DEFAULT_IMPLS
|
"MetadataSource.Property on IrFunction should only be used for synthetic \$annotations methods: ${method.render()}"
|
||||||
// TODO: fix origin somehow, because otherwise $annotations methods in interfaces also don't have ACC_SYNTHETIC
|
}
|
||||||
assert(method.name.asString().endsWith(JvmAbi.ANNOTATED_PROPERTY_METHOD_NAME_SUFFIX)) { method.dump() }
|
|
||||||
metadataSerializer.bindMethodMetadata(metadata, Method(node.name, node.desc))
|
metadataSerializer.bindMethodMetadata(metadata, Method(node.name, node.desc))
|
||||||
}
|
}
|
||||||
is MetadataSource.Function -> metadataSerializer.bindMethodMetadata(metadata, Method(node.name, node.desc))
|
is MetadataSource.Function -> metadataSerializer.bindMethodMetadata(metadata, Method(node.name, node.desc))
|
||||||
|
|||||||
+2
-1
@@ -130,7 +130,8 @@ class MethodSignatureMapper(private val context: JvmBackendContext) {
|
|||||||
private fun IrSimpleFunction.getInternalFunctionForManglingIfNeeded(): IrSimpleFunction? {
|
private fun IrSimpleFunction.getInternalFunctionForManglingIfNeeded(): IrSimpleFunction? {
|
||||||
if (origin != JvmLoweredDeclarationOrigin.STATIC_INLINE_CLASS_CONSTRUCTOR &&
|
if (origin != JvmLoweredDeclarationOrigin.STATIC_INLINE_CLASS_CONSTRUCTOR &&
|
||||||
visibility == DescriptorVisibilities.INTERNAL &&
|
visibility == DescriptorVisibilities.INTERNAL &&
|
||||||
!isPublishedApi()
|
!isPublishedApi() &&
|
||||||
|
!isSyntheticMethodForProperty
|
||||||
) {
|
) {
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -417,5 +417,5 @@ val IrDeclaration.psiElement: PsiElement?
|
|||||||
val IrMemberAccessExpression<*>.psiElement: PsiElement?
|
val IrMemberAccessExpression<*>.psiElement: PsiElement?
|
||||||
get() = (symbol.descriptor.original as? DeclarationDescriptorWithSource)?.psiElement
|
get() = (symbol.descriptor.original as? DeclarationDescriptorWithSource)?.psiElement
|
||||||
|
|
||||||
fun IrSimpleType.isRawType() =
|
fun IrSimpleType.isRawType(): Boolean =
|
||||||
hasAnnotation(JvmGeneratorExtensions.RAW_TYPE_ANNOTATION_FQ_NAME)
|
hasAnnotation(JvmGeneratorExtensions.RAW_TYPE_ANNOTATION_FQ_NAME)
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
annotation class Anno
|
||||||
|
|
||||||
|
class C {
|
||||||
|
@Anno
|
||||||
|
internal val property: Int get() = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
@Anno
|
||||||
|
internal val property: Int get() = 0
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
@java.lang.annotation.Retention
|
||||||
|
@kotlin.Metadata
|
||||||
|
public annotation class Anno {
|
||||||
|
// source: 'internalProperty.kt'
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
public final class C {
|
||||||
|
// source: 'internalProperty.kt'
|
||||||
|
public method <init>(): void
|
||||||
|
public synthetic deprecated static @Anno method getProperty$test_module$annotations(): void
|
||||||
|
public final method getProperty$test_module(): int
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
public final class InternalPropertyKt {
|
||||||
|
// source: 'internalProperty.kt'
|
||||||
|
public synthetic deprecated static @Anno method getProperty$annotations(): void
|
||||||
|
public final static method getProperty(): int
|
||||||
|
}
|
||||||
+3
@@ -17,4 +17,7 @@ class C {
|
|||||||
|
|
||||||
@Anno
|
@Anno
|
||||||
val returnType: Z get() = Z(0)
|
val returnType: Z get() = Z(0)
|
||||||
|
|
||||||
|
@Anno
|
||||||
|
internal val Z.internal: Int get() = 0
|
||||||
}
|
}
|
||||||
|
|||||||
+2
@@ -17,6 +17,8 @@ public final class AnnotatedPropertyWithInlineClassTypeInSignatureKt {
|
|||||||
public final class C {
|
public final class C {
|
||||||
// source: 'annotatedPropertyWithInlineClassTypeInSignature.kt'
|
// source: 'annotatedPropertyWithInlineClassTypeInSignature.kt'
|
||||||
public method <init>(): void
|
public method <init>(): void
|
||||||
|
public synthetic deprecated static @Anno method getInternal-IQRRRT4$test_module$annotations(p0: int): void
|
||||||
|
public final method getInternal-IQRRRT4$test_module(p0: int): int
|
||||||
public synthetic deprecated static @Anno method getMemberExtension-IQRRRT4$annotations(p0: int): void
|
public synthetic deprecated static @Anno method getMemberExtension-IQRRRT4$annotations(p0: int): void
|
||||||
public final method getMemberExtension-IQRRRT4(p0: int): int
|
public final method getMemberExtension-IQRRRT4(p0: int): int
|
||||||
public synthetic deprecated static @Anno method getReturnType-a_XrcN0$annotations(): void
|
public synthetic deprecated static @Anno method getReturnType-a_XrcN0$annotations(): void
|
||||||
|
|||||||
+5
@@ -166,6 +166,11 @@ public class BytecodeListingTestGenerated extends AbstractBytecodeListingTest {
|
|||||||
runTest("compiler/testData/codegen/bytecodeListing/annotations/deprecatedJvmOverloads.kt");
|
runTest("compiler/testData/codegen/bytecodeListing/annotations/deprecatedJvmOverloads.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("internalProperty.kt")
|
||||||
|
public void testInternalProperty() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/bytecodeListing/annotations/internalProperty.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("JvmSynthetic.kt")
|
@TestMetadata("JvmSynthetic.kt")
|
||||||
public void testJvmSynthetic() throws Exception {
|
public void testJvmSynthetic() throws Exception {
|
||||||
runTest("compiler/testData/codegen/bytecodeListing/annotations/JvmSynthetic.kt");
|
runTest("compiler/testData/codegen/bytecodeListing/annotations/JvmSynthetic.kt");
|
||||||
|
|||||||
+5
@@ -166,6 +166,11 @@ public class IrBytecodeListingTestGenerated extends AbstractIrBytecodeListingTes
|
|||||||
runTest("compiler/testData/codegen/bytecodeListing/annotations/deprecatedJvmOverloads.kt");
|
runTest("compiler/testData/codegen/bytecodeListing/annotations/deprecatedJvmOverloads.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("internalProperty.kt")
|
||||||
|
public void testInternalProperty() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/bytecodeListing/annotations/internalProperty.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("JvmSynthetic.kt")
|
@TestMetadata("JvmSynthetic.kt")
|
||||||
public void testJvmSynthetic() throws Exception {
|
public void testJvmSynthetic() throws Exception {
|
||||||
runTest("compiler/testData/codegen/bytecodeListing/annotations/JvmSynthetic.kt");
|
runTest("compiler/testData/codegen/bytecodeListing/annotations/JvmSynthetic.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user