| 
 | 1 | +/*  | 
 | 2 | + * Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.  | 
 | 3 | + */  | 
 | 4 | + | 
 | 5 | +package translators  | 
 | 6 | + | 
 | 7 | +import org.jetbrains.dokka.model.*  | 
 | 8 | +import utils.AbstractModelTest  | 
 | 9 | +import java.io.File  | 
 | 10 | +import kotlin.test.Test  | 
 | 11 | +import kotlin.test.assertTrue  | 
 | 12 | + | 
 | 13 | +class KMPTest : AbstractModelTest("/src/main/kotlin/kmp/Test.kt", "kmp") {  | 
 | 14 | + | 
 | 15 | +    // copy-pasted org.jetbrains.dokka.analysis.test.api.util.getResourceAbsolutePath  | 
 | 16 | +    private fun getResourceAbsolutePath(resourcePath: String): String {  | 
 | 17 | +        val resource = object {}.javaClass.classLoader.getResource(resourcePath)?.file  | 
 | 18 | +            ?: throw IllegalArgumentException("Resource not found: $resourcePath")  | 
 | 19 | + | 
 | 20 | +        return File(resource).absolutePath  | 
 | 21 | +    }  | 
 | 22 | + | 
 | 23 | +    val configuration = dokkaConfiguration {  | 
 | 24 | +        sourceSets {  | 
 | 25 | +            sourceSet {  | 
 | 26 | +                sourceRoots = listOf("src/androidMain/kotlin")  | 
 | 27 | +                analysisPlatform = "jvm"  | 
 | 28 | +                name = "android-example"  | 
 | 29 | +                // contains only `class Firebase`  | 
 | 30 | +                classpath = listOf(getResourceAbsolutePath("jars/jvmAndroidLib-jvm-copy.jar"))  | 
 | 31 | +            }  | 
 | 32 | +            sourceSet {  | 
 | 33 | +                sourceRoots = listOf("src/jvmMain/kotlin")  | 
 | 34 | +                analysisPlatform = "jvm"  | 
 | 35 | +                name = "jvm-example"  | 
 | 36 | +                // contains only `class Firebase`  | 
 | 37 | +                classpath = listOf(getResourceAbsolutePath("jars/jvmAndroidLib-jvm.jar"))  | 
 | 38 | +            }  | 
 | 39 | + | 
 | 40 | +        }  | 
 | 41 | +    }  | 
 | 42 | + | 
 | 43 | +    @Test  | 
 | 44 | +    fun `should resolve Firebase from the same renamed jars #3702`() {  | 
 | 45 | +        inlineModelTest(  | 
 | 46 | +            """  | 
 | 47 | +                |/src/androidMain/kotlin/main.kt  | 
 | 48 | +                |package example  | 
 | 49 | +                |import Firebase  | 
 | 50 | +                |  | 
 | 51 | +                |fun android(f: Firebase){}     | 
 | 52 | +                |               | 
 | 53 | +                |/src/jvmMain/kotlin/main.kt  | 
 | 54 | +                |package example  | 
 | 55 | +                |import Firebase  | 
 | 56 | +                |  | 
 | 57 | +                |fun jvm(f: Firebase){}  | 
 | 58 | +            """,  | 
 | 59 | +            configuration = configuration  | 
 | 60 | +        ) {  | 
 | 61 | +            with((this / "example" / "android").cast<DFunction>()) {  | 
 | 62 | +                assertTrue(parameters[0].type is GenericTypeConstructor)  | 
 | 63 | +            }  | 
 | 64 | +            with((this / "example" / "jvm").cast<DFunction>()) {  | 
 | 65 | +                assertTrue(parameters[0].type is GenericTypeConstructor)  | 
 | 66 | +            }  | 
 | 67 | +        }  | 
 | 68 | +    }  | 
 | 69 | +}  | 
0 commit comments