diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmPropertiesLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmPropertiesLowering.kt index 9152e42547a..b5af34c168c 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmPropertiesLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmPropertiesLowering.kt @@ -152,8 +152,10 @@ class JvmPropertiesLowering(private val backendContext: JvmBackendContext) : IrE private fun IrType.erasePropertyAnnotationsExtensionReceiverType(): IrType { // Use raw type of extension receiver to avoid generic signature, // which should not be generated for '...$annotations' method. - val classifier = classifierOrFail - return if (this is IrSimpleType && isArray()) { + if (this !is IrSimpleType) { + throw AssertionError("Unexpected property receiver type: $this") + } + val erasedType = if (isArray()) { when (val arg0 = arguments[0]) { is IrStarProjection -> { // 'Array<*>' becomes 'Array<*>' @@ -171,6 +173,9 @@ class JvmPropertiesLowering(private val backendContext: JvmBackendContext) : IrE } else { classifier.typeWith() } + return erasedType + .withHasQuestionMark(this.hasQuestionMark) + .addAnnotations(this.annotations) } private fun computeSyntheticMethodName(property: IrProperty): String { diff --git a/compiler/testData/codegen/bytecodeListing/annotations/kt43459.kt b/compiler/testData/codegen/bytecodeListing/annotations/kt43459.kt new file mode 100644 index 00000000000..fe074a4e3ea --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/annotations/kt43459.kt @@ -0,0 +1,10 @@ +annotation class Anno + +@Target(AnnotationTarget.TYPE) +annotation class TypeAnno + +class A { + @Anno + val @TypeAnno Int?.a: String + get() = "" +} \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeListing/annotations/kt43459.txt b/compiler/testData/codegen/bytecodeListing/annotations/kt43459.txt new file mode 100644 index 00000000000..74b6984e128 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/annotations/kt43459.txt @@ -0,0 +1,21 @@ +@kotlin.Metadata +public final class A { + // source: 'kt43459.kt' + public method (): void + public synthetic deprecated static @Anno method getA$annotations(p0: java.lang.Integer): void + public final @org.jetbrains.annotations.NotNull method getA(@org.jetbrains.annotations.Nullable p0: java.lang.Integer): java.lang.String +} + +@java.lang.annotation.Retention +@kotlin.Metadata +public annotation class Anno { + // source: 'kt43459.kt' +} + +@kotlin.annotation.Target +@java.lang.annotation.Retention +@java.lang.annotation.Target +@kotlin.Metadata +public annotation class TypeAnno { + // source: 'kt43459.kt' +} diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java index 420cb96aec1..77db5a0f348 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java @@ -246,6 +246,11 @@ public class BytecodeListingTestGenerated extends AbstractBytecodeListingTest { runTest("compiler/testData/codegen/bytecodeListing/annotations/kt43399.kt"); } + @TestMetadata("kt43459.kt") + public void testKt43459() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/annotations/kt43459.kt"); + } + @TestMetadata("kt9320.kt") public void testKt9320() throws Exception { runTest("compiler/testData/codegen/bytecodeListing/annotations/kt9320.kt"); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBytecodeListingTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBytecodeListingTestGenerated.java index fd3bfb6d9ca..aacd9cf3344 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBytecodeListingTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBytecodeListingTestGenerated.java @@ -246,6 +246,11 @@ public class IrBytecodeListingTestGenerated extends AbstractIrBytecodeListingTes runTest("compiler/testData/codegen/bytecodeListing/annotations/kt43399.kt"); } + @TestMetadata("kt43459.kt") + public void testKt43459() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/annotations/kt43459.kt"); + } + @TestMetadata("kt9320.kt") public void testKt9320() throws Exception { runTest("compiler/testData/codegen/bytecodeListing/annotations/kt9320.kt");