From 18e2b6092eb3e1c5cfbc0acf8c19d35685d93737 Mon Sep 17 00:00:00 2001 From: "Vadim.Mishenev" Date: Wed, 31 Jul 2024 18:46:31 +0300 Subject: [PATCH 1/3] [K2] Add reproducer for #3702 --- .../src/test/kotlin/translators/KMPTest.kt | 78 ++++++++++++++++++ .../resources/jars/jvmAndroidLib-jvm-copy.jar | Bin 0 -> 996 bytes .../test/resources/jars/jvmAndroidLib-jvm.jar | Bin 0 -> 996 bytes 3 files changed, 78 insertions(+) create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/translators/KMPTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/resources/jars/jvmAndroidLib-jvm-copy.jar create mode 100644 dokka-subprojects/plugin-base/src/test/resources/jars/jvmAndroidLib-jvm.jar 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..e73cf53798 --- /dev/null +++ b/dokka-subprojects/plugin-base/src/test/kotlin/translators/KMPTest.kt @@ -0,0 +1,78 @@ +/* + * 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 org.jetbrains.dokka.model.doc.* +import utils.AbstractModelTest +import utils.assertNotNull +import utils.comments +import utils.docs +import java.io.File +import kotlin.test.Test +import kotlin.test.assertTrue + +class KMPTest : AbstractModelTest("/src/main/kotlin/comment/Test.kt", "comment") { + + /// copy-pasted UTILS + 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 { + /* val common = sourceSet { + sourceRoots = listOf("src/common/kotlin") + analysisPlatform = "common" + name = "common" + }*/ + sourceSet { + sourceRoots = listOf("src/androidMain/kotlin") + analysisPlatform = "jvm" + name = "android-example" + classpath = listOf(getResourceAbsolutePath("jars/jvmAndroidLib-jvm-copy.jar")) + // dependentSourceSets = setOf(common.value.sourceSetID) + } + sourceSet { + sourceRoots = listOf("src/jvmMain/kotlin") + analysisPlatform = "jvm" + name = "jvm-example" + classpath = listOf(getResourceAbsolutePath("jars/jvmAndroidLib-jvm.jar")) + // dependentSourceSets = setOf(common.value.sourceSetID) + } + + } + } + + @Test + fun `unresolved Firebase in the android source set with the same renamed jar`() { + 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 UnresolvedBound) // <------- here + } + 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 0000000000000000000000000000000000000000..d1dc7d1386051520ba03ecc79bcb7b7b2b1ec70e GIT binary patch literal 996 zcmWIWW@Zs#VBp|jU|?_rVg?2#Fv-Bc38Z~pLmYKI{oM4K83IrgZmMT`Ck<2}3B*9{ z2!+0mex7cw!6ACSZl8V6oc8h7)w{^+t*dqJ%=yhh23L$9Jbm<(3C*z9j2fLYj0_BA zK&$zHhPh=Hr6wg7r|Ko=Bo-H^2KeS*b`Y5pYu)#Fhl#Gduf~1WPJYhqwoZ;*qEmGw zn=?c?pKkG+wy87O`Z;RVM_5=^#uc;u}s)w_d7)ko8ck1-9WJ+9HT%&Ml zp2n1irx%vb@b7N431};sc5LteoQ=+vH?Phw^QpPAUbuM0b|0=U*R;x-BN9F>h}&Jy z^?ixezMUe{&Cwx$?=zX4;3~NIr@FHF%CpQm*7{c`EFh?B+XJ!Cqk557X literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..d1dc7d1386051520ba03ecc79bcb7b7b2b1ec70e GIT binary patch literal 996 zcmWIWW@Zs#VBp|jU|?_rVg?2#Fv-Bc38Z~pLmYKI{oM4K83IrgZmMT`Ck<2}3B*9{ z2!+0mex7cw!6ACSZl8V6oc8h7)w{^+t*dqJ%=yhh23L$9Jbm<(3C*z9j2fLYj0_BA zK&$zHhPh=Hr6wg7r|Ko=Bo-H^2KeS*b`Y5pYu)#Fhl#Gduf~1WPJYhqwoZ;*qEmGw zn=?c?pKkG+wy87O`Z;RVM_5=^#uc;u}s)w_d7)ko8ck1-9WJ+9HT%&Ml zp2n1irx%vb@b7N431};sc5LteoQ=+vH?Phw^QpPAUbuM0b|0=U*R;x-BN9F>h}&Jy z^?ixezMUe{&Cwx$?=zX4;3~NIr@FHF%CpQm*7{c`EFh?B+XJ!Cqk557X literal 0 HcmV?d00001 From 8331b474a5f37f167e298e3c5a93d66e9bcc0522 Mon Sep 17 00:00:00 2001 From: vmishenev Date: Thu, 28 Nov 2024 16:31:29 +0200 Subject: [PATCH 2/3] Edit test --- .../src/test/kotlin/translators/KMPTest.kt | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/dokka-subprojects/plugin-base/src/test/kotlin/translators/KMPTest.kt b/dokka-subprojects/plugin-base/src/test/kotlin/translators/KMPTest.kt index e73cf53798..6dc9f562fa 100644 --- a/dokka-subprojects/plugin-base/src/test/kotlin/translators/KMPTest.kt +++ b/dokka-subprojects/plugin-base/src/test/kotlin/translators/KMPTest.kt @@ -5,18 +5,14 @@ package translators import org.jetbrains.dokka.model.* -import org.jetbrains.dokka.model.doc.* import utils.AbstractModelTest -import utils.assertNotNull -import utils.comments -import utils.docs import java.io.File import kotlin.test.Test import kotlin.test.assertTrue -class KMPTest : AbstractModelTest("/src/main/kotlin/comment/Test.kt", "comment") { +class KMPTest : AbstractModelTest("/src/main/kotlin/kmp/Test.kt", "kmp") { - /// copy-pasted UTILS + // 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") @@ -26,31 +22,24 @@ class KMPTest : AbstractModelTest("/src/main/kotlin/comment/Test.kt", "comment") val configuration = dokkaConfiguration { sourceSets { - /* val common = sourceSet { - sourceRoots = listOf("src/common/kotlin") - analysisPlatform = "common" - name = "common" - }*/ sourceSet { sourceRoots = listOf("src/androidMain/kotlin") analysisPlatform = "jvm" name = "android-example" classpath = listOf(getResourceAbsolutePath("jars/jvmAndroidLib-jvm-copy.jar")) - // dependentSourceSets = setOf(common.value.sourceSetID) } sourceSet { sourceRoots = listOf("src/jvmMain/kotlin") analysisPlatform = "jvm" name = "jvm-example" classpath = listOf(getResourceAbsolutePath("jars/jvmAndroidLib-jvm.jar")) - // dependentSourceSets = setOf(common.value.sourceSetID) } } } @Test - fun `unresolved Firebase in the android source set with the same renamed jar`() { + fun `should resolve Firebase from the same renamed jars #3702`() { inlineModelTest( """ |/src/androidMain/kotlin/main.kt @@ -68,7 +57,7 @@ class KMPTest : AbstractModelTest("/src/main/kotlin/comment/Test.kt", "comment") configuration = configuration ) { with((this / "example" / "android").cast()) { - assertTrue(parameters[0].type is UnresolvedBound) // <------- here + assertTrue(parameters[0].type is GenericTypeConstructor) } with((this / "example" / "jvm").cast()) { assertTrue(parameters[0].type is GenericTypeConstructor) From 814936308a6ea9fea8fdd3862167c8df446edc61 Mon Sep 17 00:00:00 2001 From: vmishenev Date: Fri, 29 Nov 2024 15:16:32 +0200 Subject: [PATCH 3/3] Left comment --- .../plugin-base/src/test/kotlin/translators/KMPTest.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dokka-subprojects/plugin-base/src/test/kotlin/translators/KMPTest.kt b/dokka-subprojects/plugin-base/src/test/kotlin/translators/KMPTest.kt index 6dc9f562fa..cfa1ec1a4c 100644 --- a/dokka-subprojects/plugin-base/src/test/kotlin/translators/KMPTest.kt +++ b/dokka-subprojects/plugin-base/src/test/kotlin/translators/KMPTest.kt @@ -26,12 +26,14 @@ class KMPTest : AbstractModelTest("/src/main/kotlin/kmp/Test.kt", "kmp") { 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")) }