diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java index e32d38de1aa..47b2a07eb63 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java @@ -223,8 +223,7 @@ public class FunctionCodegen { generateMethodAnnotations(functionDescriptor, asmMethod, mv); - JvmMethodSignature signature = typeMapper.mapSignatureSkipGeneric(functionDescriptor); - generateParameterAnnotations(functionDescriptor, mv, signature); + generateParameterAnnotations(functionDescriptor, mv, jvmSignature); GenerateJava8ParameterNamesKt.generateParameterNames(functionDescriptor, mv, jvmSignature, state, (flags & ACC_SYNTHETIC) != 0); generateBridges(functionDescriptor); diff --git a/compiler/testData/codegen/box/annotations/parameterAnnotationInDefaultImpls.kt b/compiler/testData/codegen/box/annotations/parameterAnnotationInDefaultImpls.kt new file mode 100644 index 00000000000..4584213ec6c --- /dev/null +++ b/compiler/testData/codegen/box/annotations/parameterAnnotationInDefaultImpls.kt @@ -0,0 +1,20 @@ +// FULL_JDK +// WITH_REFLECT +// IGNORE_BACKEND: JS, NATIVE + +annotation class Anno(val value: String) + +interface Test { + fun foo(@Anno("OK") a: String) = "123" +} + +fun box(): String { + val testMethod = Class.forName("Test\$DefaultImpls").declaredMethods.single() + //return (::test.parameters.single().annotations.single() as Simple).value + val receiverAnnotations = (testMethod.parameters[0]).annotations + if (receiverAnnotations.isNotEmpty()) return "fail: receiver parameter should not have any annotations, but: ${receiverAnnotations.joinToString()}" + + val value2 = ((testMethod.parameters[1]).annotations.single() as Anno).value + + return value2 +} diff --git a/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index 70b9bbe74ba..3841b4a64a6 100644 --- a/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -128,6 +128,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes doTest(fileName); } + @TestMetadata("parameterAnnotationInDefaultImpls.kt") + public void testParameterAnnotationInDefaultImpls() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/annotations/parameterAnnotationInDefaultImpls.kt"); + doTest(fileName); + } + @TestMetadata("parameterWithPrimitiveType.kt") public void testParameterWithPrimitiveType() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/annotations/parameterWithPrimitiveType.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index f76355fec6e..be116005852 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -128,6 +128,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { doTest(fileName); } + @TestMetadata("parameterAnnotationInDefaultImpls.kt") + public void testParameterAnnotationInDefaultImpls() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/annotations/parameterAnnotationInDefaultImpls.kt"); + doTest(fileName); + } + @TestMetadata("parameterWithPrimitiveType.kt") public void testParameterWithPrimitiveType() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/annotations/parameterWithPrimitiveType.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index f3b613fa9f2..3818e4ccd2a 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -140,6 +140,12 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes doTest(fileName); } + @TestMetadata("parameterAnnotationInDefaultImpls.kt") + public void testParameterAnnotationInDefaultImpls() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/annotations/parameterAnnotationInDefaultImpls.kt"); + doTest(fileName); + } + @TestMetadata("parameterWithPrimitiveType.kt") public void testParameterWithPrimitiveType() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/annotations/parameterWithPrimitiveType.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index ce268d91db3..9ad23660949 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -212,6 +212,18 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that."); } + @TestMetadata("parameterAnnotationInDefaultImpls.kt") + public void testParameterAnnotationInDefaultImpls() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/annotations/parameterAnnotationInDefaultImpls.kt"); + try { + doTest(fileName); + } + catch (Throwable ignore) { + return; + } + throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that."); + } + @TestMetadata("parameterWithPrimitiveType.kt") public void testParameterWithPrimitiveType() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/annotations/parameterWithPrimitiveType.kt");