From 231fe42c0a2cb8c59a915a5f87e349b457e53804 Mon Sep 17 00:00:00 2001 From: Igor Chevdar Date: Tue, 12 Apr 2022 10:54:33 +0500 Subject: [PATCH] [klibs] Fixed a bug in the signature-to-descriptor searcher #KT-51927 Fixed --- .../DescriptorByIdSignatureFinderImpl.kt | 2 +- .../testData/codegen/box/regressions/kt51927.kt | 15 +++++++++++++++ .../NativeCodegenBoxTestGenerated.java | 6 ++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 compiler/testData/codegen/box/regressions/kt51927.kt diff --git a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/DescriptorByIdSignatureFinderImpl.kt b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/DescriptorByIdSignatureFinderImpl.kt index 0c205003e3a..87ec8728d2d 100644 --- a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/DescriptorByIdSignatureFinderImpl.kt +++ b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/DescriptorByIdSignatureFinderImpl.kt @@ -151,7 +151,7 @@ class DescriptorByIdSignatureFinderImpl( } val candidates = acc - return candidates.singleOrNull() ?: findDescriptorByHash(candidates, signature.id) + return findDescriptorByHash(candidates, signature.id) } private fun findDescriptorByHash(candidates: Collection, id: Long?): DeclarationDescriptor? = diff --git a/compiler/testData/codegen/box/regressions/kt51927.kt b/compiler/testData/codegen/box/regressions/kt51927.kt new file mode 100644 index 00000000000..8bde1959a16 --- /dev/null +++ b/compiler/testData/codegen/box/regressions/kt51927.kt @@ -0,0 +1,15 @@ +// TARGET_BACKEND: NATIVE +// MODULE: inner +// FILE: Foo.kt +class Foo(parameter: String) + +// MODULE: outer(inner) +// FILE: FooFactory.kt +fun Foo(): Foo = Foo("") + +// MODULE: main(inner, outer) +// FILE: box.kt +fun box(): String { + Foo() + return "OK" +} \ No newline at end of file diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java index 396e217b4ac..f688fe8bc61 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java @@ -34936,6 +34936,12 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest runTest("compiler/testData/codegen/box/regressions/kt5056.kt"); } + @Test + @TestMetadata("kt51927.kt") + public void testKt51927() throws Exception { + runTest("compiler/testData/codegen/box/regressions/kt51927.kt"); + } + @Test @TestMetadata("kt5395.kt") public void testKt5395() throws Exception {