From 9eeaa967e526e7beae4de9c9b8b09ce26ff00293 Mon Sep 17 00:00:00 2001 From: Andrzej Ratajczak <32793002+BarkingBad@users.noreply.github.com> Date: Mon, 5 Oct 2020 18:14:27 +0200 Subject: Fix vararg signatures (#1516) --- .../DefaultDescriptorToDocumentableTranslator.kt | 2 +- .../base/src/test/kotlin/signatures/SignatureTest.kt | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt index d64a7b29..e1ba3cea 100644 --- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt @@ -633,7 +633,7 @@ private class DokkaDescriptorVisitor( DParameter( dri = parent.dri.copy(target = PointingToCallableParameters(index)), name = descriptor.name.asString(), - type = descriptor.type.toBound(), + type = descriptor.varargElementType?.toBound() ?: descriptor.type.toBound(), expectPresentInSet = null, documentation = descriptor.resolveDescriptorData(), sourceSets = setOf(sourceSet), diff --git a/plugins/base/src/test/kotlin/signatures/SignatureTest.kt b/plugins/base/src/test/kotlin/signatures/SignatureTest.kt index b8be54aa..f8c17794 100644 --- a/plugins/base/src/test/kotlin/signatures/SignatureTest.kt +++ b/plugins/base/src/test/kotlin/signatures/SignatureTest.kt @@ -178,6 +178,24 @@ class SignatureTest : AbstractCoreTest() { } } + @Test + fun `fun with vararg`() { + val source = source("fun simpleFun(vararg params: Int): Unit") + val writerPlugin = TestOutputWriterPlugin() + + testInline( + source, + configuration, + pluginOverrides = listOf(writerPlugin) + ) { + renderingStage = { _, _ -> + writerPlugin.writer.renderedContent("root/example/simple-fun.html").firstSignature().match( + "fun ", A("simpleFun"), "(vararg params: ", A("Int"), ")", Span() + ) + } + } + } + @Test fun `class with no supertype`() { val source = source("class SimpleClass") -- cgit