From 4c122a4d46f9f100e1508b602942c571067a1d88 Mon Sep 17 00:00:00 2001 From: Vadim Mishenev Date: Fri, 21 Oct 2022 13:59:28 +0300 Subject: Fix inheriting docs in case of diamond inheritance (#2686) --- .../base/src/test/kotlin/model/InheritorsTest.kt | 59 ++++++++++++++++++---- 1 file changed, 50 insertions(+), 9 deletions(-) (limited to 'plugins/base/src/test/kotlin') diff --git a/plugins/base/src/test/kotlin/model/InheritorsTest.kt b/plugins/base/src/test/kotlin/model/InheritorsTest.kt index 151783a9..49d02e4c 100644 --- a/plugins/base/src/test/kotlin/model/InheritorsTest.kt +++ b/plugins/base/src/test/kotlin/model/InheritorsTest.kt @@ -106,15 +106,6 @@ class InheritorsTest : AbstractModelTest("/src/main/kotlin/inheritors/Test.kt", } } } - interface A { - val a: E - } - - open class C - class B() : C(), A { - override val a: E - get() = TODO("Not yet implemented") - } @Test fun `should inherit docs`() { @@ -370,4 +361,54 @@ class InheritorsTest : AbstractModelTest("/src/main/kotlin/inheritors/Test.kt", } } } + + @Test + fun `should inherit docs in case of diamond inheritance`() { + inlineModelTest( + """ + public interface Collection2 { + /** + * Returns `true` if the collection is empty (contains no elements), `false` otherwise. + */ + public fun isEmpty(): Boolean + + /** + * Checks if the specified element is contained in this collection. + */ + public operator fun contains(element: @UnsafeVariance E): Boolean + } + + public interface MutableCollection2 : Collection2, MutableIterable2 + + + public interface List2 : Collection2 { + override fun isEmpty(): Boolean + override fun contains(element: @UnsafeVariance E): Boolean + } + + public interface MutableList2 : List2, MutableCollection2 + + public class AbstractMutableList2 : MutableList2 { + protected constructor() + + // From List + + override fun isEmpty(): Boolean = size == 0 + public override fun contains(element: E): Boolean = indexOf(element) != -1 + } + public class ArrayDeque2 : AbstractMutableList2 { + override fun isEmpty(): Boolean = size == 0 + public override fun contains(element: E): Boolean = indexOf(element) != -1 + + } + """.trimMargin() + ) { + with((this / "inheritors" / "ArrayDeque2" / "isEmpty").cast()) { + documentation.size equals 1 + } + with((this / "inheritors" / "ArrayDeque2" / "contains").cast()) { + documentation.size equals 1 + } + } + } } -- cgit