diff --git a/dokka-subprojects/plugin-base/src/test/kotlin/translators/KMPTest.kt b/dokka-subprojects/plugin-base/src/test/kotlin/translators/KMPTest.kt new file mode 100644 index 0000000000..cfa1ec1a4c --- /dev/null +++ b/dokka-subprojects/plugin-base/src/test/kotlin/translators/KMPTest.kt @@ -0,0 +1,69 @@ +/* + * Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + */ + +package translators + +import org.jetbrains.dokka.model.* +import utils.AbstractModelTest +import java.io.File +import kotlin.test.Test +import kotlin.test.assertTrue + +class KMPTest : AbstractModelTest("/src/main/kotlin/kmp/Test.kt", "kmp") { + + // copy-pasted org.jetbrains.dokka.analysis.test.api.util.getResourceAbsolutePath + private fun getResourceAbsolutePath(resourcePath: String): String { + val resource = object {}.javaClass.classLoader.getResource(resourcePath)?.file + ?: throw IllegalArgumentException("Resource not found: $resourcePath") + + return File(resource).absolutePath + } + + val configuration = dokkaConfiguration { + sourceSets { + sourceSet { + sourceRoots = listOf("src/androidMain/kotlin") + analysisPlatform = "jvm" + name = "android-example" + // contains only `class Firebase` + classpath = listOf(getResourceAbsolutePath("jars/jvmAndroidLib-jvm-copy.jar")) + } + sourceSet { + sourceRoots = listOf("src/jvmMain/kotlin") + analysisPlatform = "jvm" + name = "jvm-example" + // contains only `class Firebase` + classpath = listOf(getResourceAbsolutePath("jars/jvmAndroidLib-jvm.jar")) + } + + } + } + + @Test + fun `should resolve Firebase from the same renamed jars #3702`() { + inlineModelTest( + """ + |/src/androidMain/kotlin/main.kt + |package example + |import Firebase + | + |fun android(f: Firebase){} + | + |/src/jvmMain/kotlin/main.kt + |package example + |import Firebase + | + |fun jvm(f: Firebase){} + """, + configuration = configuration + ) { + with((this / "example" / "android").cast()) { + assertTrue(parameters[0].type is GenericTypeConstructor) + } + with((this / "example" / "jvm").cast()) { + assertTrue(parameters[0].type is GenericTypeConstructor) + } + } + } +} diff --git a/dokka-subprojects/plugin-base/src/test/resources/jars/jvmAndroidLib-jvm-copy.jar b/dokka-subprojects/plugin-base/src/test/resources/jars/jvmAndroidLib-jvm-copy.jar new file mode 100644 index 0000000000..d1dc7d1386 Binary files /dev/null and b/dokka-subprojects/plugin-base/src/test/resources/jars/jvmAndroidLib-jvm-copy.jar differ diff --git a/dokka-subprojects/plugin-base/src/test/resources/jars/jvmAndroidLib-jvm.jar b/dokka-subprojects/plugin-base/src/test/resources/jars/jvmAndroidLib-jvm.jar new file mode 100644 index 0000000000..d1dc7d1386 Binary files /dev/null and b/dokka-subprojects/plugin-base/src/test/resources/jars/jvmAndroidLib-jvm.jar differ