diff options
author | Kamil Doległo <kamilok1965@interia.pl> | 2020-02-14 00:31:47 +0100 |
---|---|---|
committer | Paweł Marks <Kordyjan@users.noreply.github.com> | 2020-02-17 15:49:57 +0100 |
commit | 8c54b7110a7947ec1694c723499d0b16a9a29ab0 (patch) | |
tree | 78622751d520e1a585ec3897341e592b808c849d /core/src/test/kotlin/basic/DRITest.kt | |
parent | c3b798fc31779468d65538b105085a3bd945792f (diff) | |
download | dokka-8c54b7110a7947ec1694c723499d0b16a9a29ab0.tar.gz dokka-8c54b7110a7947ec1694c723499d0b16a9a29ab0.tar.bz2 dokka-8c54b7110a7947ec1694c723499d0b16a9a29ab0.zip |
Fix descriptor visiting, add test for DRI clash on JS
After creating the test reproducing the DRI clash, I found a bug in the DefaultDescriptorToDocumentationTranslator, which this commit fixes. The bug was present when running the tests but not when using dokka on an external project. I have no idea how it worked, as debugging showed that the same code from AbstractClassDescriptor runs in both cases and the code contains an assert, which had to (and did) fail. Probably the error messages are being suppressed somehow. `getMemberScope()` requires a list of type substitutions which size is being compared to the type constructor's parameters count. I suppose we don't want to substitute the type parameters and get the unsubstituted member scope instead
Diffstat (limited to 'core/src/test/kotlin/basic/DRITest.kt')
-rw-r--r-- | core/src/test/kotlin/basic/DRITest.kt | 76 |
1 files changed, 71 insertions, 5 deletions
diff --git a/core/src/test/kotlin/basic/DRITest.kt b/core/src/test/kotlin/basic/DRITest.kt index 93a874ef..c7dc85fb 100644 --- a/core/src/test/kotlin/basic/DRITest.kt +++ b/core/src/test/kotlin/basic/DRITest.kt @@ -1,11 +1,13 @@ package basic import org.jetbrains.dokka.links.* +import org.jetbrains.dokka.pages.ContentPage +import org.jetbrains.dokka.pages.asSequence import org.junit.Assert.assertEquals import org.junit.Test import testApi.testRunner.AbstractCoreTest -class DRITest: AbstractCoreTest() { +class DRITest : AbstractCoreTest() { @Test fun `#634`() { val configuration = dokkaConfiguration { @@ -28,10 +30,12 @@ class DRITest: AbstractCoreTest() { configuration ) { documentablesMergingStage = { module -> - val expected = TypeConstructor("kotlin.Function1", listOf( - TypeParam(listOf(Nullable(TypeConstructor("kotlin.Any", emptyList())))), - Nullable(TypeParam(listOf(TypeConstructor("kotlin.Comparable", listOf(SelfType))))) - )) + val expected = TypeConstructor( + "kotlin.Function1", listOf( + TypeParam(listOf(Nullable(TypeConstructor("kotlin.Any", emptyList())))), + Nullable(TypeParam(listOf(TypeConstructor("kotlin.Comparable", listOf(SelfType))))) + ) + ) val actual = module.packages.single() .functions.single() .dri.callable?.params?.single() @@ -99,4 +103,66 @@ class DRITest: AbstractCoreTest() { } } } + + @Test + fun `#642 with * and Any?`() { + val configuration = dokkaConfiguration { + passes { + pass { + analysisPlatform = "js" + sourceRoots = listOf("src/") + } + } + } + + testInline( + """ + |/src/main/kotlin/Test.kt + | + |open class Bar<Z> + |class ReBarBar : Bar<StringBuilder>() + |class Foo<out T : Comparable<*>, R : List<Bar<*>>> + | + |fun <T : Comparable<Any?>> Foo<T, *>.qux(): String = TODO() + |fun <T : Comparable<*>> Foo<T, *>.qux(): String = TODO() + | + """.trimMargin(), + configuration + ) { + pagesGenerationStage = { module -> + // DRI(//qux/Foo[TypeParam(bounds=[kotlin.Comparable[kotlin.Any?]]),kotlin.Any?]#//) + val expectedDRI = DRI( + "", + null, + Callable( + "qux", + TypeConstructor( + "Foo", + listOf( + TypeParam( + listOf( + TypeConstructor( + "kotlin.Comparable", + listOf( + Nullable(TypeConstructor("kotlin.Any", emptyList())) + ) + ) + ) + ), + Nullable(TypeConstructor("kotlin.Any", emptyList())) + ) + ), + emptyList() + ) + ) + + val driCount = module + .asSequence() + .filterIsInstance<ContentPage>() + .sumBy { it.dri.count { dri -> dri == expectedDRI } } + + assertEquals(1, driCount) + } + } + } }
\ No newline at end of file |