From f5393dd740eaf533fe9ff51003b175ef1c1418fe Mon Sep 17 00:00:00 2001 From: Vadim Mishenev Date: Fri, 21 Jul 2023 15:19:17 +0300 Subject: Update Kotlin to 1.9.0 (#3074) * Update Kotlin Gradle Plugin to 1.9.0 * Update Android Gradle Plugin to 4.2.2 * Introduce convention plugin for Gradle runner https://github.com/gradle/gradle/issues/8301 * Fix unit test `common, jvm and macos source sets with kotlin multiplatform` * Update compiler to 1.9.0 * Update integration test * Add empty target for WASM integration test to avoid single target project See https://github.com/Kotlin/dokka/issues/3038 * Remove unused `plugins.shadow` from toml --- .../compiler/configuration/AnalysisEnvironment.kt | 72 ++++++++++++---------- .../resolve/DokkaJsResolverForModuleFactory.kt | 19 +++--- .../resolve/DokkaNativeResolverForModuleFactory.kt | 19 +++--- .../DefaultDescriptorToDocumentableTranslator.kt | 6 +- 4 files changed, 63 insertions(+), 53 deletions(-) (limited to 'subprojects/analysis-kotlin-descriptors/compiler/src/main') diff --git a/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/configuration/AnalysisEnvironment.kt b/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/configuration/AnalysisEnvironment.kt index ed9d887d..038a5ef7 100644 --- a/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/configuration/AnalysisEnvironment.kt +++ b/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/configuration/AnalysisEnvironment.kt @@ -343,23 +343,24 @@ class AnalysisEnvironment( moduleInfo: ModuleInfo ): ResolverForModule = CommonResolverForModuleFactory( - CommonAnalysisParameters( - metadataPartProviderFactory = { content -> - environment.createPackagePartProvider(content.moduleContentScope) - } - ), - CompilerEnvironment, - unspecifiedJvmPlatform, - true, - dependencyContainer - ).createResolverForModule( + CommonAnalysisParameters( + metadataPartProviderFactory = { content -> + environment.createPackagePartProvider(content.moduleContentScope) + } + ), + CompilerEnvironment, + unspecifiedJvmPlatform, + true, + dependencyContainer + ).createResolverForModule( moduleDescriptor = descriptor as ModuleDescriptorImpl, moduleContext = projectContext.withModule(descriptor), moduleContent = modulesContent(moduleInfo), resolverForProject = this, languageVersionSettings = LanguageVersionSettingsImpl.DEFAULT, sealedInheritorsProvider = CliSealedClassInheritorsProvider, - resolveOptimizingOptions = null + resolveOptimizingOptions = null, + absentDescriptorHandlerClass = null ) override fun sdkDependency(module: ModuleInfo): ModuleInfo? = null @@ -387,7 +388,8 @@ class AnalysisEnvironment( resolverForProject = this, languageVersionSettings = LanguageVersionSettingsImpl.DEFAULT, sealedInheritorsProvider = CliSealedClassInheritorsProvider, - resolveOptimizingOptions = null + resolveOptimizingOptions = null, + absentDescriptorHandlerClass = null ) override fun builtInsForModule(module: ModuleInfo): KotlinBuiltIns = DefaultBuiltIns.Instance @@ -419,7 +421,8 @@ class AnalysisEnvironment( resolverForProject = this, languageVersionSettings = LanguageVersionSettingsImpl.DEFAULT, sealedInheritorsProvider = CliSealedClassInheritorsProvider, - resolveOptimizingOptions = null + resolveOptimizingOptions = null, + absentDescriptorHandlerClass = null ) } @@ -464,33 +467,34 @@ class AnalysisEnvironment( descriptor: ModuleDescriptor, moduleInfo: ModuleInfo ): ResolverForModule = JvmResolverForModuleFactory( - JvmPlatformParameters(packagePartProviderFactory = { content -> - JvmPackagePartProvider( - configuration.languageVersionSettings, - content.moduleContentScope - ) - .apply { - addRoots(javaRoots, messageCollector) - } - }, moduleByJavaClass = { - val file = - (it as? BinaryJavaClass)?.virtualFile ?: (it as JavaClassImpl).psi.containingFile.virtualFile - if (file in sourcesScope) - module - else - library - }, resolverForReferencedModule = null, - useBuiltinsProviderForModule = { false }), - CompilerEnvironment, - unspecifiedJvmPlatform - ).createResolverForModule( + JvmPlatformParameters(packagePartProviderFactory = { content -> + JvmPackagePartProvider( + configuration.languageVersionSettings, + content.moduleContentScope + ) + .apply { + addRoots(javaRoots, messageCollector) + } + }, moduleByJavaClass = { + val file = + (it as? BinaryJavaClass)?.virtualFile ?: (it as JavaClassImpl).psi.containingFile.virtualFile + if (file in sourcesScope) + module + else + library + }, resolverForReferencedModule = null, + useBuiltinsProviderForModule = { false }), + CompilerEnvironment, + unspecifiedJvmPlatform + ).createResolverForModule( moduleDescriptor = descriptor as ModuleDescriptorImpl, moduleContext = projectContext.withModule(descriptor), moduleContent = modulesContent(moduleInfo), resolverForProject = this, languageVersionSettings = configuration.languageVersionSettings, sealedInheritorsProvider = CliSealedClassInheritorsProvider, - resolveOptimizingOptions = null + resolveOptimizingOptions = null, + absentDescriptorHandlerClass = null ) override fun sdkDependency(module: ModuleInfo): ModuleInfo? = null diff --git a/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/configuration/resolve/DokkaJsResolverForModuleFactory.kt b/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/configuration/resolve/DokkaJsResolverForModuleFactory.kt index bb6148ad..c1965db2 100644 --- a/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/configuration/resolve/DokkaJsResolverForModuleFactory.kt +++ b/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/configuration/resolve/DokkaJsResolverForModuleFactory.kt @@ -23,6 +23,7 @@ import org.jetbrains.kotlin.serialization.js.DynamicTypeDeserializer import org.jetbrains.kotlin.serialization.js.KotlinJavascriptSerializationUtil import org.jetbrains.kotlin.serialization.js.createKotlinJavascriptPackageFragmentProvider import org.jetbrains.kotlin.library.metadata.impl.KlibMetadataModuleDescriptorFactoryImpl +import org.jetbrains.kotlin.resolve.lazy.AbsentDescriptorHandler import org.jetbrains.kotlin.resolve.scopes.optimization.OptimizingOptions import org.jetbrains.kotlin.utils.KotlinJavascriptMetadataUtils import java.io.File @@ -50,7 +51,8 @@ internal class DokkaJsResolverForModuleFactory( resolverForProject: ResolverForProject, languageVersionSettings: LanguageVersionSettings, sealedInheritorsProvider: SealedClassInheritorsProvider, - resolveOptimizingOptions: OptimizingOptions? + resolveOptimizingOptions: OptimizingOptions?, + absentDescriptorHandlerClass: Class? ): ResolverForModule { val declarationProviderFactory = DeclarationProviderFactoryService.createDeclarationProviderFactory( moduleContext.project, @@ -61,13 +63,14 @@ internal class DokkaJsResolverForModuleFactory( ) val container = createContainerForLazyResolve( - moduleContext, - declarationProviderFactory, - CodeAnalyzerInitializer.getInstance(moduleContext.project).createTrace(), // BindingTraceContext(/* allowSliceRewrite = */ true), - moduleDescriptor.platform!!, - JsPlatformAnalyzerServices, - targetEnvironment, - languageVersionSettings + moduleContext = moduleContext, + declarationProviderFactory = declarationProviderFactory, + bindingTrace = CodeAnalyzerInitializer.getInstance(moduleContext.project).createTrace(), // BindingTraceContext(/* allowSliceRewrite = */ true), + platform = moduleDescriptor.platform!!, + analyzerServices = JsPlatformAnalyzerServices, + targetEnvironment = targetEnvironment, + languageVersionSettings = languageVersionSettings, + absentDescriptorHandlerClass = absentDescriptorHandlerClass ) var packageFragmentProvider = container.get().packageFragmentProvider diff --git a/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/configuration/resolve/DokkaNativeResolverForModuleFactory.kt b/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/configuration/resolve/DokkaNativeResolverForModuleFactory.kt index ff1eb491..00b2bd68 100644 --- a/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/configuration/resolve/DokkaNativeResolverForModuleFactory.kt +++ b/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/configuration/resolve/DokkaNativeResolverForModuleFactory.kt @@ -16,6 +16,7 @@ import org.jetbrains.kotlin.resolve.CodeAnalyzerInitializer import org.jetbrains.kotlin.resolve.SealedClassInheritorsProvider import org.jetbrains.kotlin.resolve.TargetEnvironment import org.jetbrains.kotlin.resolve.konan.platform.NativePlatformAnalyzerServices +import org.jetbrains.kotlin.resolve.lazy.AbsentDescriptorHandler import org.jetbrains.kotlin.resolve.lazy.ResolveSession import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProviderFactoryService import org.jetbrains.kotlin.resolve.scopes.optimization.OptimizingOptions @@ -36,7 +37,8 @@ internal class DokkaNativeResolverForModuleFactory( resolverForProject: ResolverForProject, languageVersionSettings: LanguageVersionSettings, sealedInheritorsProvider: SealedClassInheritorsProvider, - resolveOptimizingOptions: OptimizingOptions? + resolveOptimizingOptions: OptimizingOptions?, + absentDescriptorHandlerClass: Class? ): ResolverForModule { val declarationProviderFactory = DeclarationProviderFactoryService.createDeclarationProviderFactory( @@ -48,13 +50,14 @@ internal class DokkaNativeResolverForModuleFactory( ) val container = createContainerForLazyResolve( - moduleContext, - declarationProviderFactory, - CodeAnalyzerInitializer.getInstance(moduleContext.project).createTrace(), - moduleDescriptor.platform!!, - NativePlatformAnalyzerServices, - targetEnvironment, - languageVersionSettings + moduleContext = moduleContext, + declarationProviderFactory = declarationProviderFactory, + bindingTrace = CodeAnalyzerInitializer.getInstance(moduleContext.project).createTrace(), + platform = moduleDescriptor.platform!!, + analyzerServices = NativePlatformAnalyzerServices, + targetEnvironment = targetEnvironment, + languageVersionSettings = languageVersionSettings, + absentDescriptorHandlerClass = absentDescriptorHandlerClass ) var packageFragmentProvider = container.get().packageFragmentProvider diff --git a/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/translator/DefaultDescriptorToDocumentableTranslator.kt b/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/translator/DefaultDescriptorToDocumentableTranslator.kt index cb52236e..08313503 100644 --- a/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/translator/DefaultDescriptorToDocumentableTranslator.kt +++ b/subprojects/analysis-kotlin-descriptors/compiler/src/main/kotlin/org/jetbrains/dokka/analysis/kotlin/descriptors/compiler/translator/DefaultDescriptorToDocumentableTranslator.kt @@ -1149,14 +1149,14 @@ private class DokkaDescriptorVisitor( fullEnumEntryName(), DRI(enumClassId.packageFqName.asString(), fullEnumEntryName()) ) - is ConstantsKtClassValue -> when (value) { - is NormalClass -> (value as NormalClass).value.classId.let { + is ConstantsKtClassValue -> when (val value = value) { + is NormalClass -> value.classId.let { ClassValue( it.relativeClassName.asString(), DRI(it.packageFqName.asString(), it.relativeClassName.asString()) ) } - is LocalClass -> (value as LocalClass).type.let { + is LocalClass -> value.type.let { ClassValue( it.toString(), DRI.from(it.constructor.declarationDescriptor as DeclarationDescriptor) -- cgit