diff --git a/compiler/testData/codegen/box/reflection/mapping/constructorWithInlineClassParameters.kt b/compiler/testData/codegen/box/reflection/mapping/constructorWithInlineClassParameters.kt new file mode 100644 index 00000000000..4a95f1d44a7 --- /dev/null +++ b/compiler/testData/codegen/box/reflection/mapping/constructorWithInlineClassParameters.kt @@ -0,0 +1,21 @@ +// IGNORE_BACKEND: JVM_IR, JS_IR, JS, NATIVE +// WITH_REFLECT +import kotlin.reflect.full.primaryConstructor +import kotlin.reflect.jvm.javaConstructor +import kotlin.reflect.jvm.kotlinFunction +import kotlin.test.assertEquals + +inline class Z(val x: Int) + +class Test(val x: Z) + +fun box(): String { + val kctor1 = Test::class.primaryConstructor ?: throw AssertionError("No primary constructor") + val jctor1 = kctor1.javaConstructor ?: throw AssertionError("No javaConstructor for $kctor1") + val kctor2 = jctor1.kotlinFunction ?: throw AssertionError("No kotlinFunction for $jctor1") + + assertEquals(kctor1, kctor2) + assertEquals("[x]", kctor2.parameters.map { it.name }.toString()) + + return "OK" +} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index 863955f2840..014e8b2514c 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -20200,6 +20200,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/reflection/mapping/constructor.kt"); } + @TestMetadata("constructorWithInlineClassParameters.kt") + public void testConstructorWithInlineClassParameters() throws Exception { + runTest("compiler/testData/codegen/box/reflection/mapping/constructorWithInlineClassParameters.kt"); + } + @TestMetadata("extensionProperty.kt") public void testExtensionProperty() throws Exception { runTest("compiler/testData/codegen/box/reflection/mapping/extensionProperty.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index d7c0da62e91..8763929b4f3 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -20200,6 +20200,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/reflection/mapping/constructor.kt"); } + @TestMetadata("constructorWithInlineClassParameters.kt") + public void testConstructorWithInlineClassParameters() throws Exception { + runTest("compiler/testData/codegen/box/reflection/mapping/constructorWithInlineClassParameters.kt"); + } + @TestMetadata("extensionProperty.kt") public void testExtensionProperty() throws Exception { runTest("compiler/testData/codegen/box/reflection/mapping/extensionProperty.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index 6735de74cc1..0b10bc032e7 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -20205,6 +20205,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/reflection/mapping/constructor.kt"); } + @TestMetadata("constructorWithInlineClassParameters.kt") + public void testConstructorWithInlineClassParameters() throws Exception { + runTest("compiler/testData/codegen/box/reflection/mapping/constructorWithInlineClassParameters.kt"); + } + @TestMetadata("extensionProperty.kt") public void testExtensionProperty() throws Exception { runTest("compiler/testData/codegen/box/reflection/mapping/extensionProperty.kt"); diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/ReflectJvmMapping.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/ReflectJvmMapping.kt index 84e4a4cede2..8ed8136bcfa 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/ReflectJvmMapping.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/ReflectJvmMapping.kt @@ -144,7 +144,5 @@ val Method.kotlinFunction: KFunction<*>? */ val Constructor.kotlinFunction: KFunction? get() { - if (isSynthetic) return null - return declaringClass.kotlin.constructors.firstOrNull { it.javaConstructor == this } } diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrJsCodegenBoxTestGenerated.java index b841fa8a2ad..7df061536cd 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrJsCodegenBoxTestGenerated.java @@ -17665,6 +17665,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/reflection/mapping/constructor.kt"); } + @TestMetadata("constructorWithInlineClassParameters.kt") + public void testConstructorWithInlineClassParameters() throws Exception { + runTest("compiler/testData/codegen/box/reflection/mapping/constructorWithInlineClassParameters.kt"); + } + @TestMetadata("extensionProperty.kt") public void testExtensionProperty() throws Exception { runTest("compiler/testData/codegen/box/reflection/mapping/extensionProperty.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 1c709fad860..fd58ec951a6 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 @@ -18720,6 +18720,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/reflection/mapping/constructor.kt"); } + @TestMetadata("constructorWithInlineClassParameters.kt") + public void testConstructorWithInlineClassParameters() throws Exception { + runTest("compiler/testData/codegen/box/reflection/mapping/constructorWithInlineClassParameters.kt"); + } + @TestMetadata("extensionProperty.kt") public void testExtensionProperty() throws Exception { runTest("compiler/testData/codegen/box/reflection/mapping/extensionProperty.kt");