JVM_IR: fields for deprecated enum entries have ACC_DEPRECATED flag
'Deprecated' annotation can't be applied to field itself.
This commit is contained in:
+6
-2
@@ -366,6 +366,7 @@ private val IrClass.flags: Int
|
|||||||
private val IrField.flags: Int
|
private val IrField.flags: Int
|
||||||
get() = origin.flags or visibility.flags or
|
get() = origin.flags or visibility.flags or
|
||||||
this.specialDeprecationFlag or (correspondingPropertySymbol?.owner?.deprecationFlags ?: 0) 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 (isFinal) Opcodes.ACC_FINAL else 0) or
|
||||||
(if (isStatic) Opcodes.ACC_STATIC else 0) or
|
(if (isStatic) Opcodes.ACC_STATIC else 0) or
|
||||||
(if (hasAnnotation(VOLATILE_ANNOTATION_FQ_NAME)) Opcodes.ACC_VOLATILE 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
|
private val IrField.specialDeprecationFlag: Int
|
||||||
get() = if (shouldHaveSpecialDeprecationFlag()) Opcodes.ACC_DEPRECATED else 0
|
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 &&
|
return origin == IrDeclarationOrigin.FIELD_FOR_OBJECT_INSTANCE &&
|
||||||
annotations.hasAnnotation(FqName("java.lang.Deprecated"))
|
annotations.hasAnnotation(JAVA_LANG_DEPRECATED)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val IrDeclarationOrigin.flags: Int
|
private val IrDeclarationOrigin.flags: Int
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
// WITH_RUNTIME
|
||||||
|
|
||||||
|
enum class Test {
|
||||||
|
@Deprecated("") ENTRY1,
|
||||||
|
ENTRY2,
|
||||||
|
@Deprecated("") ENTRY3
|
||||||
|
}
|
||||||
@@ -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 <clinit>(): void
|
||||||
|
private method <init>(p0: java.lang.String, p1: int): void
|
||||||
|
public static method valueOf(p0: java.lang.String): Test
|
||||||
|
public static method values(): Test[]
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
@Deprecated("")
|
||||||
|
lateinit var lateinitVar: String
|
||||||
@@ -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
|
||||||
|
}
|
||||||
+10
@@ -49,6 +49,16 @@ public class BytecodeListingTestGenerated extends AbstractBytecodeListingTest {
|
|||||||
runTest("compiler/testData/codegen/bytecodeListing/defaultImpls.kt");
|
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")
|
@TestMetadata("emptyMultifileFacade.kt")
|
||||||
public void testEmptyMultifileFacade() throws Exception {
|
public void testEmptyMultifileFacade() throws Exception {
|
||||||
runTest("compiler/testData/codegen/bytecodeListing/emptyMultifileFacade.kt");
|
runTest("compiler/testData/codegen/bytecodeListing/emptyMultifileFacade.kt");
|
||||||
|
|||||||
+10
@@ -49,6 +49,16 @@ public class IrBytecodeListingTestGenerated extends AbstractIrBytecodeListingTes
|
|||||||
runTest("compiler/testData/codegen/bytecodeListing/defaultImpls.kt");
|
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")
|
@TestMetadata("emptyMultifileFacade.kt")
|
||||||
public void testEmptyMultifileFacade() throws Exception {
|
public void testEmptyMultifileFacade() throws Exception {
|
||||||
runTest("compiler/testData/codegen/bytecodeListing/emptyMultifileFacade.kt");
|
runTest("compiler/testData/codegen/bytecodeListing/emptyMultifileFacade.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user