diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/ir/IrUtils.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/ir/IrUtils.kt index a620a4afdb0..7887beea575 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/ir/IrUtils.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/ir/IrUtils.kt @@ -137,7 +137,7 @@ fun IrValueParameter.copyTo( (parent as IrTypeParametersContainer).classIfConstructor, irFunction.classIfConstructor ), - varargElementType: IrType? = this.varargElementType, + varargElementType: IrType? = this.varargElementType, // TODO: remapTypeParameters here as well defaultValue: IrExpressionBody? = this.defaultValue, isCrossinline: Boolean = this.isCrossinline, isNoinline: Boolean = this.isNoinline diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/PropertiesLowering.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/PropertiesLowering.kt index 7e1ac6cad59..c7ae4c40975 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/PropertiesLowering.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/PropertiesLowering.kt @@ -9,6 +9,7 @@ import org.jetbrains.kotlin.backend.common.BackendContext import org.jetbrains.kotlin.backend.common.FileLoweringPass import org.jetbrains.kotlin.backend.common.descriptors.WrappedSimpleFunctionDescriptor import org.jetbrains.kotlin.backend.common.ir.copyTo +import org.jetbrains.kotlin.backend.common.ir.copyTypeParametersFrom import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.ir.IrElement @@ -19,7 +20,10 @@ import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl import org.jetbrains.kotlin.ir.expressions.impl.IrBlockBodyImpl import org.jetbrains.kotlin.ir.expressions.impl.IrBlockImpl import org.jetbrains.kotlin.ir.symbols.impl.IrSimpleFunctionSymbolImpl +import org.jetbrains.kotlin.ir.types.classifierOrFail +import org.jetbrains.kotlin.ir.types.typeWith import org.jetbrains.kotlin.ir.util.isEffectivelyExternal +import org.jetbrains.kotlin.ir.util.render import org.jetbrains.kotlin.ir.util.transformDeclarationsFlat import org.jetbrains.kotlin.ir.visitors.* import org.jetbrains.kotlin.name.Name @@ -81,7 +85,11 @@ class PropertiesLowering( ).apply { descriptor.bind(this) - extensionReceiverParameter = declaration.getter?.extensionReceiverParameter?.copyTo(this) + val extensionReceiver = declaration.getter?.extensionReceiverParameter + if (extensionReceiver != null) { + // Use raw type of extension receiver to avoid generic signature, which would be useless for this method. + extensionReceiverParameter = extensionReceiver.copyTo(this, type = extensionReceiver.type.classifierOrFail.typeWith()) + } body = IrBlockBodyImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET) diff --git a/compiler/testData/codegen/box/reflection/annotations/genericExtensionProperty.kt b/compiler/testData/codegen/box/reflection/annotations/genericExtensionProperty.kt new file mode 100644 index 00000000000..ba05011d5b5 --- /dev/null +++ b/compiler/testData/codegen/box/reflection/annotations/genericExtensionProperty.kt @@ -0,0 +1,16 @@ +// TARGET_BACKEND: JVM +// WITH_REFLECT + +@Retention(AnnotationRetention.RUNTIME) +annotation class Simple(val value: String) + +interface A + +@Simple("OK") +public val A.p: String + get() = TODO() + +fun box(): String { + val o = object : A {} + return (o::p.annotations.single() as Simple).value +} diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index abab992e723..368083939b1 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -20301,6 +20301,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/reflection/annotations/findAnnotation.kt"); } + @TestMetadata("genericExtensionProperty.kt") + public void testGenericExtensionProperty() throws Exception { + runTest("compiler/testData/codegen/box/reflection/annotations/genericExtensionProperty.kt"); + } + @TestMetadata("hasAnnotation.kt") public void testHasAnnotation() throws Exception { runTest("compiler/testData/codegen/box/reflection/annotations/hasAnnotation.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 665219d5cc9..5988f64177b 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -20301,6 +20301,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/reflection/annotations/findAnnotation.kt"); } + @TestMetadata("genericExtensionProperty.kt") + public void testGenericExtensionProperty() throws Exception { + runTest("compiler/testData/codegen/box/reflection/annotations/genericExtensionProperty.kt"); + } + @TestMetadata("hasAnnotation.kt") public void testHasAnnotation() throws Exception { runTest("compiler/testData/codegen/box/reflection/annotations/hasAnnotation.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index 34dd73c2f44..0745636b55a 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -19186,6 +19186,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/reflection/annotations/findAnnotation.kt"); } + @TestMetadata("genericExtensionProperty.kt") + public void testGenericExtensionProperty() throws Exception { + runTest("compiler/testData/codegen/box/reflection/annotations/genericExtensionProperty.kt"); + } + @TestMetadata("hasAnnotation.kt") public void testHasAnnotation() throws Exception { runTest("compiler/testData/codegen/box/reflection/annotations/hasAnnotation.kt");