From 76c26f3325ebe0c06779fca09bbef0eefac5aa5a Mon Sep 17 00:00:00 2001 From: Marcin Aman Date: Thu, 6 May 2021 11:09:42 +0200 Subject: Bump compiler to 1.5.0 (#1856) * Bump compiler to 1.5.0 * Include Api changes --- .../DefaultDescriptorToDocumentableTranslator.kt | 3 +- plugins/base/src/test/kotlin/model/ClassesTest.kt | 34 +++++++++++++++++++++ .../base/src/test/kotlin/model/InheritorsTest.kt | 35 +++++++++++++--------- 3 files changed, 57 insertions(+), 15 deletions(-) (limited to 'plugins/base') diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt index 4ddd2d39..92ffd9b6 100644 --- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt @@ -901,10 +901,11 @@ private class DokkaDescriptorVisitor( private fun ClassDescriptor.additionalExtras() = listOfNotNull( ExtraModifiers.KotlinOnlyModifiers.Inline.takeIf { isInline }, + ExtraModifiers.KotlinOnlyModifiers.Value.takeIf { isValue }, ExtraModifiers.KotlinOnlyModifiers.External.takeIf { isExternal }, ExtraModifiers.KotlinOnlyModifiers.Inner.takeIf { isInner }, ExtraModifiers.KotlinOnlyModifiers.Data.takeIf { isData }, - ExtraModifiers.KotlinOnlyModifiers.Fun.takeIf { isFun } + ExtraModifiers.KotlinOnlyModifiers.Fun.takeIf { isFun }, ).toSet() private fun ValueParameterDescriptor.additionalExtras() = listOfNotNull( diff --git a/plugins/base/src/test/kotlin/model/ClassesTest.kt b/plugins/base/src/test/kotlin/model/ClassesTest.kt index 34857ad8..b05ed4fb 100644 --- a/plugins/base/src/test/kotlin/model/ClassesTest.kt +++ b/plugins/base/src/test/kotlin/model/ClassesTest.kt @@ -553,4 +553,38 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class } } } + + @Test + fun `inline classes`() { + inlineModelTest( + """ + | inline class X(val example: String) + | + | @JvmInline + | value class InlineTest(val x: String) + """.trimMargin() + ) { + val classlike = packages.flatMap { it.classlikes }.first() as DClass + classlike.name equals "X" + classlike.properties.first().name equals "example" + classlike.extra[AdditionalModifiers]?.content?.values?.firstOrNull() + ?.firstOrNull() equals ExtraModifiers.KotlinOnlyModifiers.Inline + } + } + + @Test + fun `value classes`() { + inlineModelTest( + """ + | @JvmInline + | value class InlineTest(val example: String) + """.trimMargin() + ) { + val classlike = packages.flatMap { it.classlikes }.first() as DClass + classlike.name equals "InlineTest" + classlike.properties.first().name equals "example" + classlike.extra[AdditionalModifiers]?.content?.values?.firstOrNull() + ?.firstOrNull() equals ExtraModifiers.KotlinOnlyModifiers.Value + } + } } diff --git a/plugins/base/src/test/kotlin/model/InheritorsTest.kt b/plugins/base/src/test/kotlin/model/InheritorsTest.kt index 503cf50c..2b0aff62 100644 --- a/plugins/base/src/test/kotlin/model/InheritorsTest.kt +++ b/plugins/base/src/test/kotlin/model/InheritorsTest.kt @@ -1,33 +1,22 @@ package model -import org.jetbrains.dokka.CoreExtensions import org.jetbrains.dokka.Platform -import org.jetbrains.dokka.base.transformers.documentables.InheritorsExtractorTransformer import org.jetbrains.dokka.base.transformers.documentables.InheritorsInfo +import org.jetbrains.dokka.model.DClass import org.jetbrains.dokka.model.DInterface -import org.jetbrains.dokka.plugability.DokkaPlugin import org.junit.jupiter.api.Assertions.assertTrue -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import utils.AbstractModelTest import utils.assertNotNull class InheritorsTest : AbstractModelTest("/src/main/kotlin/inheritors/Test.kt", "inheritors") { - object InheritorsPlugin : DokkaPlugin() { - val inheritors by extending { - CoreExtensions.documentableTransformer with InheritorsExtractorTransformer() - } - } - - @Disabled("reenable after fixing subtypes") @Test fun simple() { inlineModelTest( """|interface A{} |class B() : A {} """.trimMargin(), - pluginsOverrides = listOf(InheritorsPlugin) ) { with((this / "inheritors" / "A").cast()) { val map = extra[InheritorsInfo].assertNotNull("InheritorsInfo").value @@ -40,7 +29,26 @@ class InheritorsTest : AbstractModelTest("/src/main/kotlin/inheritors/Test.kt", } } - @Disabled("reenable after fixing subtypes") + @Test + fun sealed() { + inlineModelTest( + """|sealed class A {} + |class B() : A() {} + |class C() : A() {} + |class D() + """.trimMargin(), + ) { + with((this / "inheritors" / "A").cast()) { + val map = extra[InheritorsInfo].assertNotNull("InheritorsInfo").value + with(map.keys.also { it counts 1 }.find { it.analysisPlatform == Platform.jvm }.assertNotNull("jvm key").let { map[it]!! } + ) { + this counts 2 + mapNotNull { it.classNames }.sorted() equals listOf("B", "C") + } + } + } + } + @Test fun multiplatform() { val configuration = dokkaConfiguration { @@ -71,7 +79,6 @@ class InheritorsTest : AbstractModelTest("/src/main/kotlin/inheritors/Test.kt", """.trimMargin(), configuration, cleanupOutput = false, - pluginOverrides = listOf(InheritorsPlugin) ) { documentablesTransformationStage = { m -> with((m / "inheritors" / "A").cast()) { -- cgit