diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/CAdapterGenerator.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/CAdapterGenerator.kt index 7a42008931e..c80f5b8f054 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/CAdapterGenerator.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/CAdapterGenerator.kt @@ -635,7 +635,7 @@ internal class CAdapterGenerator(val context: Context) : DeclarationDescriptorVi private val seenPackageFragments = mutableSetOf() private var currentPackageFragments: List = emptyList() - private val packageScopes = mutableMapOf() + private val packageScopes = mutableMapOf() override fun visitModuleDeclaration(descriptor: ModuleDescriptor, ignored: Void?): Boolean { TODO("Shall not be called directly") @@ -648,8 +648,8 @@ internal class CAdapterGenerator(val context: Context) : DeclarationDescriptorVi override fun visitPackageFragmentDescriptor(descriptor: PackageFragmentDescriptor, ignored: Void?): Boolean { val fqName = descriptor.fqName - val name = if (fqName.isRoot) "root" else translateName(fqName.shortName().asString()) - val packageScope = packageScopes.getOrPut(name) { + val packageScope = packageScopes.getOrPut(fqName) { + val name = if (fqName.isRoot) "root" else translateName(fqName.shortName().asString()) val scope = ExportedElementScope(ScopeKind.PACKAGE, name) scopes.last().scopes += scope scope diff --git a/backend.native/tests/produce_dynamic/simple/hello.kt b/backend.native/tests/produce_dynamic/simple/hello.kt index 8ad57b40641..3ea037214a5 100644 --- a/backend.native/tests/produce_dynamic/simple/hello.kt +++ b/backend.native/tests/produce_dynamic/simple/hello.kt @@ -3,6 +3,8 @@ * that can be found in the LICENSE file. */ +// FILE: hello.kt + import kotlinx.cinterop.* import kotlin.native.CName @@ -141,3 +143,15 @@ fun getNullableString(param: Int) : String? { } fun getVector128() = vectorOf(1, 2, 3, 4) + +// FILE: gh3952.sync.kt + +package gh3952.sync + +class PlainSync {} + +// FILE: gh3952.nested.sync.kt + +package gh3952.nested.sync + +class NestedSync {} diff --git a/backend.native/tests/produce_dynamic/simple/main.c b/backend.native/tests/produce_dynamic/simple/main.c index 7ddbf5353aa..ce0bbfa540b 100644 --- a/backend.native/tests/produce_dynamic/simple/main.c +++ b/backend.native/tests/produce_dynamic/simple/main.c @@ -14,6 +14,16 @@ void testVector128() { printf("getVector128 = (%d, %d, %d, %d)\n", v4f[0], v4f[1], v4f[2], v4f[3]); } +// See https://github.com/JetBrains/kotlin-native/issues/3952 +void testGH3952() { + T_(gh3952_nested_sync_NestedSync) good = __ kotlin.root.gh3952.nested.sync.NestedSync.NestedSync(); + + T_(gh3952_sync_PlainSync) alsoGood = __ kotlin.root.gh3952.sync.PlainSync.PlainSync(); + + __ DisposeStablePointer(good.pinned); + __ DisposeStablePointer(alsoGood.pinned); +} + int main(void) { T_(Singleton) singleton = __ kotlin.root.Singleton._instance(); T_(Base) base = __ kotlin.root.Base.Base(); @@ -74,6 +84,7 @@ int main(void) { printf("IsInstance2 = %s\n", !(__ IsInstance(singleton.pinned, __ kotlin.root.Codeable._type())) ? "PASS" : "FAIL"); testVector128(); + testGH3952(); __ DisposeStablePointer(singleton.pinned); __ DisposeString(string1);