JVM IR: Don't create $annotations stubs for fake overridden properties

This commit is contained in:
Steven Schäfer
2020-02-19 15:16:16 +01:00
committed by Alexander Udalov
parent 3eed0609b2
commit 2b6a0d6c58
4 changed files with 21 additions and 1 deletions
@@ -55,7 +55,7 @@ class JvmPropertiesLowering(private val context: JvmBackendContext) : IrElementT
addIfNotNull(declaration.getter)
addIfNotNull(declaration.setter)
if (declaration.annotations.isNotEmpty()) {
if (!declaration.isFakeOverride && declaration.annotations.isNotEmpty()) {
add(createSyntheticMethodForAnnotations(declaration))
}
}
@@ -0,0 +1,10 @@
annotation class Ann
abstract class Base {
@Ann val x: Int = 0
}
class Derived : Base()
// We only want to generate the `getX$annotations` method in `Base`, not in `Derived`.
// 1 @LAnn;\(\)
@@ -119,6 +119,11 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
runTest("compiler/testData/codegen/bytecodeText/flagsInMultiFileInherit.kt");
}
@TestMetadata("inheritedPropertyAnnotations.kt")
public void testInheritedPropertyAnnotations() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/inheritedPropertyAnnotations.kt");
}
@TestMetadata("inlineFromOtherModule.kt")
public void testInlineFromOtherModule() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/inlineFromOtherModule.kt");
@@ -119,6 +119,11 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest {
runTest("compiler/testData/codegen/bytecodeText/flagsInMultiFileInherit.kt");
}
@TestMetadata("inheritedPropertyAnnotations.kt")
public void testInheritedPropertyAnnotations() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/inheritedPropertyAnnotations.kt");
}
@TestMetadata("inlineFromOtherModule.kt")
public void testInlineFromOtherModule() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/inlineFromOtherModule.kt");