diff --git a/dokka-subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/kdoc/SyntheticKDocProvider.kt b/dokka-subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/kdoc/SyntheticKDocProvider.kt index 2c466186ff..d8c8192ff6 100644 --- a/dokka-subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/kdoc/SyntheticKDocProvider.kt +++ b/dokka-subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/kdoc/SyntheticKDocProvider.kt @@ -9,7 +9,6 @@ import org.jetbrains.dokka.analysis.markdown.jb.MarkdownParser import org.jetbrains.dokka.model.doc.DocumentationNode import org.jetbrains.kotlin.analysis.api.KaSession import org.jetbrains.kotlin.analysis.api.symbols.* -import org.jetbrains.kotlin.analysis.api.symbols.markers.KaPossibleMemberSymbol import org.jetbrains.kotlin.builtins.StandardNames private const val ENUM_ENTRIES_TEMPLATE_PATH = "/dokka/docs/kdoc/EnumEntries.kt.template" @@ -33,7 +32,7 @@ private fun KaSession.getDocumentationTemplatePath(symbol: KaSymbol): String? = else -> null } -private fun KaSession.isEnumSpecialMember(symbol: KaPossibleMemberSymbol): Boolean = +private fun KaSession.isEnumSpecialMember(symbol: KaSymbol): Boolean = symbol.origin == KaSymbolOrigin.SOURCE_MEMBER_GENERATED && (symbol.containingSymbol as? KaClassSymbol)?.classKind == KaClassKind.ENUM_CLASS diff --git a/dokka-subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/translators/DRIFactory.kt b/dokka-subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/translators/DRIFactory.kt index b4708b25ef..78abc6225d 100644 --- a/dokka-subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/translators/DRIFactory.kt +++ b/dokka-subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/translators/DRIFactory.kt @@ -5,10 +5,10 @@ package org.jetbrains.dokka.analysis.kotlin.symbols.translators import org.jetbrains.dokka.links.* +import org.jetbrains.kotlin.analysis.api.KaExperimentalApi import org.jetbrains.kotlin.analysis.api.KaSession import org.jetbrains.kotlin.analysis.api.symbols.* import org.jetbrains.kotlin.analysis.api.symbols.markers.KaNamedSymbol -import org.jetbrains.kotlin.analysis.api.symbols.markers.KaSymbolWithTypeParameters import org.jetbrains.kotlin.analysis.api.types.* import org.jetbrains.kotlin.name.CallableId import org.jetbrains.kotlin.name.ClassId @@ -41,9 +41,9 @@ internal fun getDRIFromEnumEntry(symbol: KaEnumEntrySymbol): DRI { } +@OptIn(KaExperimentalApi::class) // due to `typeParameters` internal fun KaSession.getDRIFromTypeParameter(symbol: KaTypeParameterSymbol): DRI { - val containingSymbol = - (symbol.containingSymbol as? KaSymbolWithTypeParameters) + val containingSymbol = symbol.containingSymbol ?: throw IllegalStateException("Containing symbol is null for type parameter") val typeParameters = containingSymbol.typeParameters val index = typeParameters.indexOfFirst { symbol.name == it.name } diff --git a/dokka-subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/translators/DefaultSymbolToDocumentableTranslator.kt b/dokka-subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/translators/DefaultSymbolToDocumentableTranslator.kt index f312b27f00..6ea176754c 100644 --- a/dokka-subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/translators/DefaultSymbolToDocumentableTranslator.kt +++ b/dokka-subprojects/analysis-kotlin-symbols/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/symbols/translators/DefaultSymbolToDocumentableTranslator.kt @@ -34,12 +34,7 @@ import org.jetbrains.kotlin.KtNodeTypes import org.jetbrains.kotlin.analysis.api.* import org.jetbrains.kotlin.analysis.api.annotations.KaAnnotated import org.jetbrains.kotlin.analysis.api.symbols.* -import org.jetbrains.kotlin.analysis.api.symbols.markers.KaSymbolWithModality -import org.jetbrains.kotlin.analysis.api.symbols.markers.KaSymbolWithVisibility import org.jetbrains.kotlin.analysis.api.types.* -import org.jetbrains.kotlin.descriptors.Modality -import org.jetbrains.kotlin.descriptors.Visibilities -import org.jetbrains.kotlin.descriptors.java.JavaVisibilities import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.lexer.KtTokens @@ -529,14 +524,6 @@ internal class DokkaSymbolVisitor( val inheritedFrom = dri.getInheritedFromDRI(parent) val isExpect = false val isActual = false - val generics = - javaFieldSymbol.typeParameters.mapIndexed { index, symbol -> - visitVariantTypeParameter( - index, - symbol, - dri - ) - } return DProperty( dri = dri, @@ -556,7 +543,7 @@ internal class DokkaSymbolVisitor( type = toBoundFrom(javaFieldSymbol.returnType), expectPresentInSet = sourceSet.takeIf { isExpect }, sourceSets = setOf(sourceSet), - generics = generics, + generics = emptyList(), isExpectActual = (isExpect || isActual), extra = PropertyContainer.withAll( javaFieldSymbol.additionalExtras()?.toSourceSetDependent()?.toAdditionalModifiers(), @@ -886,26 +873,26 @@ internal class DokkaSymbolVisitor( // ----------- Translators of modifiers ---------------------------------------------------------------------------- - private fun KaSymbolWithModality.getDokkaModality(): KotlinModifier { + private fun KaDeclarationSymbol.getDokkaModality(): KotlinModifier { val isInterface = this is KaClassSymbol && classKind == KaClassKind.INTERFACE return if (isInterface) { // only two modalities are possible for interfaces: // - `SEALED` - when it's declared as `sealed interface` // - `ABSTRACT` - when it's declared as `interface` or `abstract interface` (`abstract` is redundant but possible here) when (modality) { - Modality.SEALED -> KotlinModifier.Sealed + KaSymbolModality.SEALED -> KotlinModifier.Sealed else -> KotlinModifier.Empty } } else { when (modality) { - Modality.FINAL -> KotlinModifier.Final - Modality.SEALED -> KotlinModifier.Sealed - Modality.OPEN -> KotlinModifier.Open - Modality.ABSTRACT -> KotlinModifier.Abstract + KaSymbolModality.FINAL -> KotlinModifier.Final + KaSymbolModality.SEALED -> KotlinModifier.Sealed + KaSymbolModality.OPEN -> KotlinModifier.Open + KaSymbolModality.ABSTRACT -> KotlinModifier.Abstract } } } - private fun KaSymbolWithVisibility.getDokkaVisibility() = visibility.toDokkaVisibility() + private fun KaDeclarationSymbol.getDokkaVisibility() = visibility.toDokkaVisibility() private fun KaValueParameterSymbol.additionalExtras() = listOfNotNull( ExtraModifiers.KotlinOnlyModifiers.NoInline.takeIf { isNoinline }, ExtraModifiers.KotlinOnlyModifiers.CrossInline.takeIf { isCrossinline }, @@ -952,15 +939,14 @@ internal class DokkaSymbolVisitor( ExtraModifiers.KotlinOnlyModifiers.Fun.takeIf { isFun }, ).toSet().takeUnless { it.isEmpty() } - private fun org.jetbrains.kotlin.descriptors.Visibility.toDokkaVisibility(): Visibility = when (this) { - Visibilities.Public -> KotlinVisibility.Public - Visibilities.Protected -> KotlinVisibility.Protected - Visibilities.Internal -> KotlinVisibility.Internal - Visibilities.Private, Visibilities.PrivateToThis -> KotlinVisibility.Private - JavaVisibilities.ProtectedAndPackage -> KotlinVisibility.Protected - JavaVisibilities.ProtectedStaticVisibility -> KotlinVisibility.Protected - JavaVisibilities.PackageVisibility -> JavaVisibility.Default - else -> KotlinVisibility.Public + private fun KaSymbolVisibility.toDokkaVisibility(): Visibility = when (this) { + KaSymbolVisibility.PUBLIC -> KotlinVisibility.Public + KaSymbolVisibility.PROTECTED -> KotlinVisibility.Protected + KaSymbolVisibility.INTERNAL -> KotlinVisibility.Internal + KaSymbolVisibility.PRIVATE -> KotlinVisibility.Private + KaSymbolVisibility.PACKAGE_PROTECTED -> KotlinVisibility.Protected + KaSymbolVisibility.PACKAGE_PRIVATE -> JavaVisibility.Default + KaSymbolVisibility.UNKNOWN, KaSymbolVisibility.LOCAL -> KotlinVisibility.Public } } diff --git a/dokka-subprojects/plugin-base/src/test/kotlin/model/PropertyTest.kt b/dokka-subprojects/plugin-base/src/test/kotlin/model/PropertyTest.kt index b9f02f24c4..286b3974ba 100644 --- a/dokka-subprojects/plugin-base/src/test/kotlin/model/PropertyTest.kt +++ b/dokka-subprojects/plugin-base/src/test/kotlin/model/PropertyTest.kt @@ -274,4 +274,32 @@ class PropertyTest : AbstractModelTest("/src/main/kotlin/property/Test.kt", "pro } } } + + @Test + fun `member properties and Java fields should have no generic params in kotlin`() { + inlineModelTest( + """ + |/src/sample/ParentInKotlin.kt + |package sample + | + | class KtContainer : MyContainer() { + | val ktProp: T + |} + | + |/src/sample/MyContainer.java + |package sample; + | + |public class MyContainer { + | public T prop; + |} + """.trimIndent() + ) { + with((this / "sample" / "KtContainer" / "prop").cast()) { + generics counts 0 + } + with((this / "sample" / "KtContainer" / "ktProp").cast()) { + generics counts 0 + } + } + } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 2c35b3b094..29cb089175 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -14,7 +14,7 @@ kotlinx-bcv = "0.13.2" # Version of compiler for analysis-descriptor is in sync with K2 because of updated intellij-platform in 2.0.20-dev-5055 # can be changed to just 2.0.20 after release of Kotlin 2.0.20 kotlin-compiler = "2.0.20-dev-5135" -kotlin-compiler-k2 = "2.0.20-dev-6911" +kotlin-compiler-k2 = "2.0.20-dev-7572" # MUST match the version of the intellij platform used in the kotlin compiler, # otherwise this will lead to different versions of psi API and implementations