diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ClassCodegen.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ClassCodegen.kt index c9761e642fc..919e109f090 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ClassCodegen.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ClassCodegen.kt @@ -366,6 +366,7 @@ private val IrClass.flags: Int private val IrField.flags: Int get() = origin.flags or visibility.flags or this.specialDeprecationFlag or (correspondingPropertySymbol?.owner?.deprecationFlags ?: 0) or + (if (annotations.hasAnnotation(KOTLIN_DEPRECATED)) Opcodes.ACC_DEPRECATED else 0) or (if (isFinal) Opcodes.ACC_FINAL else 0) or (if (isStatic) Opcodes.ACC_STATIC else 0) or (if (hasAnnotation(VOLATILE_ANNOTATION_FQ_NAME)) Opcodes.ACC_VOLATILE else 0) or @@ -375,9 +376,12 @@ private val IrField.flags: Int private val IrField.specialDeprecationFlag: Int get() = if (shouldHaveSpecialDeprecationFlag()) Opcodes.ACC_DEPRECATED else 0 -private fun IrField.shouldHaveSpecialDeprecationFlag(): Boolean { +private val JAVA_LANG_DEPRECATED = FqName("java.lang.Deprecated") +private val KOTLIN_DEPRECATED = FqName("kotlin.Deprecated") + +fun IrField.shouldHaveSpecialDeprecationFlag(): Boolean { return origin == IrDeclarationOrigin.FIELD_FOR_OBJECT_INSTANCE && - annotations.hasAnnotation(FqName("java.lang.Deprecated")) + annotations.hasAnnotation(JAVA_LANG_DEPRECATED) } private val IrDeclarationOrigin.flags: Int diff --git a/compiler/testData/codegen/bytecodeListing/deprecatedEnumEntryFields.kt b/compiler/testData/codegen/bytecodeListing/deprecatedEnumEntryFields.kt new file mode 100644 index 00000000000..e7186a70d93 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/deprecatedEnumEntryFields.kt @@ -0,0 +1,7 @@ +// WITH_RUNTIME + +enum class Test { + @Deprecated("") ENTRY1, + ENTRY2, + @Deprecated("") ENTRY3 +} diff --git a/compiler/testData/codegen/bytecodeListing/deprecatedEnumEntryFields.txt b/compiler/testData/codegen/bytecodeListing/deprecatedEnumEntryFields.txt new file mode 100644 index 00000000000..00948df0ce1 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/deprecatedEnumEntryFields.txt @@ -0,0 +1,11 @@ +@kotlin.Metadata +public final enum class Test { + private synthetic final static field $VALUES: Test[] + public deprecated final enum static @kotlin.Deprecated field ENTRY1: Test + public final enum static field ENTRY2: Test + public deprecated final enum static @kotlin.Deprecated field ENTRY3: Test + static method (): void + private method (p0: java.lang.String, p1: int): void + public static method valueOf(p0: java.lang.String): Test + public static method values(): Test[] +} diff --git a/compiler/testData/codegen/bytecodeListing/deprecatedLateinitVar.kt b/compiler/testData/codegen/bytecodeListing/deprecatedLateinitVar.kt new file mode 100644 index 00000000000..ad47d1e23a2 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/deprecatedLateinitVar.kt @@ -0,0 +1,2 @@ +@Deprecated("") +lateinit var lateinitVar: String \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeListing/deprecatedLateinitVar.txt b/compiler/testData/codegen/bytecodeListing/deprecatedLateinitVar.txt new file mode 100644 index 00000000000..2e91904a662 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/deprecatedLateinitVar.txt @@ -0,0 +1,7 @@ +@kotlin.Metadata +public final class DeprecatedLateinitVarKt { + public deprecated static field lateinitVar: java.lang.String + public synthetic deprecated static @kotlin.Deprecated method getLateinitVar$annotations(): void + public deprecated final static @org.jetbrains.annotations.NotNull method getLateinitVar(): java.lang.String + public deprecated final static method setLateinitVar(@org.jetbrains.annotations.NotNull p0: java.lang.String): void +} diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java index 8081ae7c57f..5b740166e4d 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java @@ -49,6 +49,16 @@ public class BytecodeListingTestGenerated extends AbstractBytecodeListingTest { runTest("compiler/testData/codegen/bytecodeListing/defaultImpls.kt"); } + @TestMetadata("deprecatedEnumEntryFields.kt") + public void testDeprecatedEnumEntryFields() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/deprecatedEnumEntryFields.kt"); + } + + @TestMetadata("deprecatedLateinitVar.kt") + public void testDeprecatedLateinitVar() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/deprecatedLateinitVar.kt"); + } + @TestMetadata("emptyMultifileFacade.kt") public void testEmptyMultifileFacade() throws Exception { runTest("compiler/testData/codegen/bytecodeListing/emptyMultifileFacade.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeListingTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeListingTestGenerated.java index 06ebc42deab..5ac2ebe01c6 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeListingTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeListingTestGenerated.java @@ -49,6 +49,16 @@ public class IrBytecodeListingTestGenerated extends AbstractIrBytecodeListingTes runTest("compiler/testData/codegen/bytecodeListing/defaultImpls.kt"); } + @TestMetadata("deprecatedEnumEntryFields.kt") + public void testDeprecatedEnumEntryFields() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/deprecatedEnumEntryFields.kt"); + } + + @TestMetadata("deprecatedLateinitVar.kt") + public void testDeprecatedLateinitVar() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/deprecatedLateinitVar.kt"); + } + @TestMetadata("emptyMultifileFacade.kt") public void testEmptyMultifileFacade() throws Exception { runTest("compiler/testData/codegen/bytecodeListing/emptyMultifileFacade.kt");