JVM IR: recover accidentally lost backingField (KT-49998)

This commit is contained in:
Xin Wang
2021-12-10 14:46:46 +08:00
committed by Alexander Udalov
parent b6b5ecc352
commit 944fa7e2f8
7 changed files with 65 additions and 0 deletions
@@ -53,6 +53,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/annotations/annotatedObjectLiteral.kt");
}
@Test
@TestMetadata("annotationDefaultValueOfUnsigned.kt")
public void testAnnotationDefaultValueOfUnsigned() throws Exception {
runTest("compiler/testData/codegen/box/annotations/annotationDefaultValueOfUnsigned.kt");
}
@Test
@TestMetadata("annotationOnWhen.kt")
public void testAnnotationOnWhen() throws Exception {
@@ -49,6 +49,12 @@ public class FirBytecodeTextTestGenerated extends AbstractFirBytecodeTextTest {
runTest("compiler/testData/codegen/bytecodeText/annotationDefaultValue.kt");
}
@Test
@TestMetadata("annotationDefaultValueOfUnsigned.kt")
public void testAnnotationDefaultValueOfUnsigned() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/annotationDefaultValueOfUnsigned.kt");
}
@Test
@TestMetadata("annotationJavaRetentionPolicyRuntime.kt")
public void testAnnotationJavaRetentionPolicyRuntime() throws Exception {
@@ -290,6 +290,7 @@ class MemoizedInlineClassReplacements(
parent = propertySymbol.owner.parent
copyAttributes(propertySymbol.owner)
annotations = propertySymbol.owner.annotations
backingField = propertySymbol.owner.backingField
}
}
correspondingPropertySymbol = property.symbol
@@ -0,0 +1,29 @@
// TARGET_BACKEND: JVM_IR
// WITH_STDLIB
// WITH_REFLECT
// FULL_JDK
annotation class Ann1(val value: UByte = 41u)
annotation class Ann2(val value: UShort = 42u)
annotation class Ann3(val value: UInt = 43u)
annotation class Ann4(val value: ULong = 44u)
@Ann1
@Ann2
@Ann3
@Ann4
class A
fun box(): String {
val default1 = A::class.java.getAnnotation(Ann1::class.java).value
val default2 = A::class.java.getAnnotation(Ann2::class.java).value
val default3 = A::class.java.getAnnotation(Ann3::class.java).value
val default4 = A::class.java.getAnnotation(Ann4::class.java).value
return if (default1 == 41u.toUByte() &&
default2 == 42u.toUShort() &&
default3 == 43u &&
default4 == 44u.toULong()
) "OK"
else "FAIL"
}
@@ -0,0 +1,11 @@
// TARGET_BACKEND: JVM_IR
annotation class Ann1(val value: UByte = 41u)
annotation class Ann2(val value: UShort = 42u)
annotation class Ann3(val value: UInt = 43u)
annotation class Ann4(val value: ULong = 44u)
// 1 default=\(byte\)41
// 1 default=\(short\)42
// 1 default=43
// 1 default=44L
@@ -53,6 +53,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/annotations/annotatedObjectLiteral.kt");
}
@Test
@TestMetadata("annotationDefaultValueOfUnsigned.kt")
public void testAnnotationDefaultValueOfUnsigned() throws Exception {
runTest("compiler/testData/codegen/box/annotations/annotationDefaultValueOfUnsigned.kt");
}
@Test
@TestMetadata("annotationOnWhen.kt")
public void testAnnotationOnWhen() throws Exception {
@@ -49,6 +49,12 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest {
runTest("compiler/testData/codegen/bytecodeText/annotationDefaultValue.kt");
}
@Test
@TestMetadata("annotationDefaultValueOfUnsigned.kt")
public void testAnnotationDefaultValueOfUnsigned() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/annotationDefaultValueOfUnsigned.kt");
}
@Test
@TestMetadata("annotationJavaRetentionPolicyRuntime.kt")
public void testAnnotationJavaRetentionPolicyRuntime() throws Exception {