diff --git a/dokka-subprojects/plugin-base/src/test/kotlin/content/inheritors/ContentForInheritorsTest.kt b/dokka-subprojects/plugin-base/src/test/kotlin/content/inheritors/ContentForInheritorsTest.kt index cb1b906235..62ced2c701 100644 --- a/dokka-subprojects/plugin-base/src/test/kotlin/content/inheritors/ContentForInheritorsTest.kt +++ b/dokka-subprojects/plugin-base/src/test/kotlin/content/inheritors/ContentForInheritorsTest.kt @@ -9,11 +9,16 @@ import org.jetbrains.dokka.DokkaConfiguration import org.jetbrains.dokka.PluginConfigurationImpl import org.jetbrains.dokka.base.DokkaBase import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest +import org.jetbrains.dokka.links.DRI +import org.jetbrains.dokka.model.dfs +import org.jetbrains.dokka.pages.MemberPageNode import utils.OnlyDescriptors import utils.classSignature import utils.findTestType import kotlin.test.Test import kotlin.test.assertEquals +import kotlin.test.assertNotNull +import kotlin.test.assertNull class ContentForInheritorsTest : BaseAbstractTest() { private val testConfiguration = dokkaConfiguration { @@ -501,4 +506,94 @@ class ContentForInheritorsTest : BaseAbstractTest() { } } } + + @Test + fun `fake intersected and overridden fake function does not generate redundant page`() { + testInline( + """ + |/src/main/kotlin/test/source.kt + |package test + | + |class NamedDomainObjectContainerScope + | : NamedDomainObjectContainerDelegate(), PolymorphicDomainObjectContainer + | + |abstract class NamedDomainObjectContainerDelegate : NamedDomainObjectContainer { + | override fun getNamer(): T? = null + |} + | + |interface PolymorphicDomainObjectContainer: NamedDomainObjectContainer + | + |interface NamedDomainObjectContainer { + | fun getNamer(): T? = null + |} + """.trimMargin(), + testConfiguration + ) { + pagesTransformationStage = { module -> + val targetDRI = DRI( + "test", + "NamedDomainObjectContainerDelegate", + org.jetbrains.dokka.links.Callable("getNamer", null, emptyList()) + ) + val fakeDRI = DRI( + "test", + "NamedDomainObjectContainerScope", + org.jetbrains.dokka.links.Callable("getNamer", null, emptyList()) + ) + assertNull( + module.dfs { it.name == "getNamer" && (it as? MemberPageNode)?.dri?.singleOrNull() == fakeDRI }, + "There should be no page for NamedDomainObjectContainerScope::getNamer" + ) + assertNotNull( + module.dfs { it.name == "getNamer" && (it as? MemberPageNode)?.dri?.singleOrNull() == targetDRI }, + "There should be a page for NamedDomainObjectContainerScope::getNamer" + ) + } + } + } + + @Test + fun `fake intersected and overridden fake property does not generate redundant page`() { + testInline( + """ + |/src/main/kotlin/test/source.kt + |package test + | + |class NamedDomainObjectContainerScope + | : NamedDomainObjectContainerDelegate(), PolymorphicDomainObjectContainer + | + |abstract class NamedDomainObjectContainerDelegate : NamedDomainObjectContainer { + | override var namer: T? = null + |} + | + |interface PolymorphicDomainObjectContainer: NamedDomainObjectContainer + | + |interface NamedDomainObjectContainer { + | var namer: T? = null + |} + """.trimMargin(), + testConfiguration + ) { + pagesTransformationStage = { module -> + val targetDRI = DRI( + "test", + "NamedDomainObjectContainerDelegate", + org.jetbrains.dokka.links.Callable("namer", null, emptyList()) + ) + val fakeDRI = DRI( + "test", + "NamedDomainObjectContainerScope", + org.jetbrains.dokka.links.Callable("namer", null, emptyList()) + ) + assertNull( + module.dfs { it.name == "namer" && (it as? MemberPageNode)?.dri?.singleOrNull() == fakeDRI }, + "There should be no page for NamedDomainObjectContainerScope::namer" + ) + assertNotNull( + module.dfs { it.name == "namer" && (it as? MemberPageNode)?.dri?.singleOrNull() == targetDRI }, + "There should be a page for NamedDomainObjectContainerScope::namer" + ) + } + } + } } diff --git a/dokka-subprojects/plugin-base/src/test/kotlin/model/InheritorsTest.kt b/dokka-subprojects/plugin-base/src/test/kotlin/model/InheritorsTest.kt index f2ac64b288..bed46aa8fc 100644 --- a/dokka-subprojects/plugin-base/src/test/kotlin/model/InheritorsTest.kt +++ b/dokka-subprojects/plugin-base/src/test/kotlin/model/InheritorsTest.kt @@ -756,4 +756,52 @@ class InheritorsTest : AbstractModelTest("/src/main/kotlin/inheritors/Test.kt", } } } + + @Test + fun `fake intersected and overridden fake fun should have correct DRI`() { + inlineModelTest( + """ + |class NamedDomainObjectContainerScope + | : NamedDomainObjectContainerDelegate(), PolymorphicDomainObjectContainer + | + |abstract class NamedDomainObjectContainerDelegate : NamedDomainObjectContainer { + | override fun getNamer(): T? = null + |} + | + |interface PolymorphicDomainObjectContainer: NamedDomainObjectContainer + | + |interface NamedDomainObjectContainer { + | fun getNamer(): T? = null + |} + """ + ) { + with((this / "inheritors" / "NamedDomainObjectContainerScope" / "getNamer").cast()) { + dri equals DRI("inheritors", "NamedDomainObjectContainerDelegate", org.jetbrains.dokka.links.Callable("getNamer", null, emptyList()) ) + } + } + } + + @Test + fun `fake intersected and overridden fake property should have correct DRI`() { + inlineModelTest( + """ + |class NamedDomainObjectContainerScope + | : NamedDomainObjectContainerDelegate(), PolymorphicDomainObjectContainer + | + |abstract class NamedDomainObjectContainerDelegate : NamedDomainObjectContainer { + | override var namer: T? = null + |} + | + |interface PolymorphicDomainObjectContainer: NamedDomainObjectContainer + | + |interface NamedDomainObjectContainer { + | var namer: T? = null + |} + """ + ) { + with((this / "inheritors" / "NamedDomainObjectContainerScope" / "namer").cast()) { + dri equals DRI("inheritors", "NamedDomainObjectContainerDelegate", org.jetbrains.dokka.links.Callable("namer", null, emptyList()) ) + } + } + } } \ No newline at end of file