Remove obsolete compiler argument -Xsingle-module

#KT-51622
This commit is contained in:
Alexander Udalov
2022-08-26 13:16:00 +02:00
parent abaffeddab
commit a76de14026
6 changed files with 9 additions and 37 deletions
@@ -200,9 +200,6 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
) )
var declarationsOutputPath: String? by NullableStringFreezableVar(null) var declarationsOutputPath: String? by NullableStringFreezableVar(null)
@Argument(value = "-Xsingle-module", description = "Combine modules for source files and binary dependencies into a single module")
var singleModule: Boolean by FreezableVar(false)
@Argument( @Argument(
value = "-Xsuppress-missing-builtins-error", value = "-Xsuppress-missing-builtins-error",
description = "Suppress the \"cannot access built-in declaration\" error (useful with -no-stdlib)" description = "Suppress the \"cannot access built-in declaration\" error (useful with -no-stdlib)"
@@ -45,8 +45,8 @@ import org.jetbrains.kotlin.frontend.java.di.initJvmBuiltInsForTopDownAnalysis
import org.jetbrains.kotlin.frontend.java.di.initialize import org.jetbrains.kotlin.frontend.java.di.initialize
import org.jetbrains.kotlin.incremental.components.EnumWhenTracker import org.jetbrains.kotlin.incremental.components.EnumWhenTracker
import org.jetbrains.kotlin.incremental.components.ExpectActualTracker import org.jetbrains.kotlin.incremental.components.ExpectActualTracker
import org.jetbrains.kotlin.incremental.components.LookupTracker
import org.jetbrains.kotlin.incremental.components.InlineConstTracker import org.jetbrains.kotlin.incremental.components.InlineConstTracker
import org.jetbrains.kotlin.incremental.components.LookupTracker
import org.jetbrains.kotlin.ir.backend.jvm.jvmLibrariesProvidedByDefault import org.jetbrains.kotlin.ir.backend.jvm.jvmLibrariesProvidedByDefault
import org.jetbrains.kotlin.javac.components.JavacBasedClassFinder import org.jetbrains.kotlin.javac.components.JavacBasedClassFinder
import org.jetbrains.kotlin.javac.components.JavacBasedSourceElementFactory import org.jetbrains.kotlin.javac.components.JavacBasedSourceElementFactory
@@ -80,7 +80,6 @@ import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProviderFactory
import org.jetbrains.kotlin.resolve.lazy.declarations.FileBasedDeclarationProviderFactory import org.jetbrains.kotlin.resolve.lazy.declarations.FileBasedDeclarationProviderFactory
import org.jetbrains.kotlin.storage.LockBasedStorageManager import org.jetbrains.kotlin.storage.LockBasedStorageManager
import org.jetbrains.kotlin.storage.StorageManager import org.jetbrains.kotlin.storage.StorageManager
import java.util.*
import kotlin.reflect.KFunction1 import kotlin.reflect.KFunction1
object TopDownAnalyzerFacadeForJVM { object TopDownAnalyzerFacadeForJVM {
@@ -135,7 +134,6 @@ object TopDownAnalyzerFacadeForJVM {
return AnalysisResult.success(trace.bindingContext, module) return AnalysisResult.success(trace.bindingContext, module)
} }
@OptIn(ExperimentalStdlibApi::class)
fun createContainer( fun createContainer(
project: Project, project: Project,
files: Collection<KtFile>, files: Collection<KtFile>,
@@ -167,10 +165,7 @@ object TopDownAnalyzerFacadeForJVM {
val enumWhenTracker = configuration.get(CommonConfigurationKeys.ENUM_WHEN_TRACKER) ?: EnumWhenTracker.DoNothing val enumWhenTracker = configuration.get(CommonConfigurationKeys.ENUM_WHEN_TRACKER) ?: EnumWhenTracker.DoNothing
val targetIds = configuration.get(JVMConfigurationKeys.MODULES)?.map(::TargetId) val targetIds = configuration.get(JVMConfigurationKeys.MODULES)?.map(::TargetId)
val separateModules = !configuration.getBoolean(JVMConfigurationKeys.USE_SINGLE_MODULE) val moduleClassResolver = SourceOrBinaryModuleClassResolver(sourceModuleSearchScope)
val sourceScope = if (separateModules) sourceModuleSearchScope else GlobalSearchScope.allScope(project)
val moduleClassResolver = SourceOrBinaryModuleClassResolver(sourceScope)
val fallbackBuiltIns = JvmBuiltIns(storageManager, JvmBuiltIns.Kind.FALLBACK).apply { val fallbackBuiltIns = JvmBuiltIns(storageManager, JvmBuiltIns.Kind.FALLBACK).apply {
initialize(builtInsModule, languageVersionSettings) initialize(builtInsModule, languageVersionSettings)
@@ -187,14 +182,14 @@ object TopDownAnalyzerFacadeForJVM {
if (configuration.getBoolean(JVMConfigurationKeys.USE_JAVAC)) StorageComponentContainer::useJavac if (configuration.getBoolean(JVMConfigurationKeys.USE_JAVAC)) StorageComponentContainer::useJavac
else null as KFunction1<StorageComponentContainer, Unit>? else null as KFunction1<StorageComponentContainer, Unit>?
val dependencyModule = if (separateModules) { val dependencyModule = run {
val dependenciesContext = ContextForNewModule( val dependenciesContext = ContextForNewModule(
moduleContext, Name.special("<dependencies of ${configuration.getNotNull(CommonConfigurationKeys.MODULE_NAME)}>"), moduleContext, Name.special("<dependencies of ${configuration.getNotNull(CommonConfigurationKeys.MODULE_NAME)}>"),
module.builtIns, jvmPlatform module.builtIns, jvmPlatform
) )
// Scope for the dependency module contains everything except files present in the scope for the source module // Scope for the dependency module contains everything except files present in the scope for the source module
val dependencyScope = GlobalSearchScope.notScope(sourceScope) val dependencyScope = GlobalSearchScope.notScope(sourceModuleSearchScope)
val dependenciesContainer = createContainerForLazyResolveWithJava( val dependenciesContainer = createContainerForLazyResolveWithJava(
jvmPlatform, jvmPlatform,
@@ -220,9 +215,9 @@ object TopDownAnalyzerFacadeForJVM {
) )
) )
dependenciesContext.module dependenciesContext.module
} else null }
val partProvider = packagePartProvider(sourceScope).let { fragment -> val partProvider = packagePartProvider(sourceModuleSearchScope).let { fragment ->
if (targetIds == null || incrementalComponents == null) fragment if (targetIds == null || incrementalComponents == null) fragment
else IncrementalPackagePartProvider(fragment, targetIds.map(incrementalComponents::getIncrementalCache)) else IncrementalPackagePartProvider(fragment, targetIds.map(incrementalComponents::getIncrementalCache))
} }
@@ -233,7 +228,7 @@ object TopDownAnalyzerFacadeForJVM {
// TODO: get rid of duplicate invocation of CodeAnalyzerInitializer#initialize, or refactor CliLightClassGenerationSupport // TODO: get rid of duplicate invocation of CodeAnalyzerInitializer#initialize, or refactor CliLightClassGenerationSupport
val container = createContainerForLazyResolveWithJava( val container = createContainerForLazyResolveWithJava(
jvmPlatform, jvmPlatform,
moduleContext, trace, declarationProviderFactory(storageManager, files), sourceScope, moduleClassResolver, moduleContext, trace, declarationProviderFactory(storageManager, files), sourceModuleSearchScope, moduleClassResolver,
targetEnvironment, lookupTracker, expectActualTracker, inlineConstTracker, enumWhenTracker, targetEnvironment, lookupTracker, expectActualTracker, inlineConstTracker, enumWhenTracker,
partProvider, languageVersionSettings, partProvider, languageVersionSettings,
useBuiltInsProvider = true, useBuiltInsProvider = true,
@@ -267,23 +262,9 @@ object TopDownAnalyzerFacadeForJVM {
val klibModules = getKlibModules(klibList, dependencyModule) val klibModules = getKlibModules(klibList, dependencyModule)
// TODO: remove dependencyModule from friends // TODO: remove dependencyModule from friends
val dependencies = buildList {
add(module)
dependencyModule?.let { add(it) }
add(fallbackBuiltIns)
addAll(klibModules)
@Suppress("UNCHECKED_CAST")
addAll(explicitModuleDependencyList)
}
val friends = buildSet {
if (dependencyModule != null) {
add(dependencyModule)
}
addAll(explicitModuleFriendsList)
}
module.setDependencies( module.setDependencies(
dependencies, listOf(module, dependencyModule, fallbackBuiltIns) + klibModules + explicitModuleDependencyList,
friends setOf(dependencyModule) + explicitModuleFriendsList,
) )
module.initialize( module.initialize(
CompositePackageFragmentProvider( CompositePackageFragmentProvider(
@@ -338,7 +338,6 @@ fun CompilerConfiguration.configureAdvancedJvmOptions(arguments: K2JVMCompilerAr
put(CLIConfigurationKeys.ALLOW_KOTLIN_PACKAGE, arguments.allowKotlinPackage) put(CLIConfigurationKeys.ALLOW_KOTLIN_PACKAGE, arguments.allowKotlinPackage)
put(CLIConfigurationKeys.RENDER_DIAGNOSTIC_INTERNAL_NAME, arguments.renderInternalDiagnosticNames) put(CLIConfigurationKeys.RENDER_DIAGNOSTIC_INTERNAL_NAME, arguments.renderInternalDiagnosticNames)
put(JVMConfigurationKeys.USE_SINGLE_MODULE, arguments.singleModule)
put(JVMConfigurationKeys.USE_OLD_INLINE_CLASSES_MANGLING_SCHEME, arguments.useOldInlineClassesManglingScheme) put(JVMConfigurationKeys.USE_OLD_INLINE_CLASSES_MANGLING_SCHEME, arguments.useOldInlineClassesManglingScheme)
put(JVMConfigurationKeys.ENABLE_JVM_PREVIEW, arguments.enableJvmPreview) put(JVMConfigurationKeys.ENABLE_JVM_PREVIEW, arguments.enableJvmPreview)
@@ -58,9 +58,6 @@ public class JVMConfigurationKeys {
public static final CompilerConfigurationKey<Boolean> USE_TYPE_TABLE = public static final CompilerConfigurationKey<Boolean> USE_TYPE_TABLE =
CompilerConfigurationKey.create("use type table in serializer"); CompilerConfigurationKey.create("use type table in serializer");
public static final CompilerConfigurationKey<Boolean> USE_SINGLE_MODULE =
CompilerConfigurationKey.create("combine modules for source files and binary dependencies into a single module");
public static final CompilerConfigurationKey<JvmTarget> JVM_TARGET = public static final CompilerConfigurationKey<JvmTarget> JVM_TARGET =
CompilerConfigurationKey.create("JVM bytecode target version"); CompilerConfigurationKey.create("JVM bytecode target version");
-1
View File
@@ -124,7 +124,6 @@ where advanced options include:
Script resolver environment in key-value pairs (the value could be quoted and escaped) Script resolver environment in key-value pairs (the value could be quoted and escaped)
-Xserialize-ir={none|inline|all} -Xserialize-ir={none|inline|all}
Save IR to metadata (EXPERIMENTAL) Save IR to metadata (EXPERIMENTAL)
-Xsingle-module Combine modules for source files and binary dependencies into a single module
-Xgenerate-strict-metadata-version -Xgenerate-strict-metadata-version
Generate metadata with strict version semantics (see kdoc on Metadata.extraInt) Generate metadata with strict version semantics (see kdoc on Metadata.extraInt)
-Xstring-concat={indy-with-constants|indy|inline} -Xstring-concat={indy-with-constants|indy|inline}
@@ -150,7 +150,6 @@ class CompilerArgumentsContentProspectorTest {
K2JVMCompilerArguments::inheritMultifileParts, K2JVMCompilerArguments::inheritMultifileParts,
K2JVMCompilerArguments::useTypeTable, K2JVMCompilerArguments::useTypeTable,
K2JVMCompilerArguments::useOldClassFilesReading, K2JVMCompilerArguments::useOldClassFilesReading,
K2JVMCompilerArguments::singleModule,
K2JVMCompilerArguments::suppressMissingBuiltinsError, K2JVMCompilerArguments::suppressMissingBuiltinsError,
K2JVMCompilerArguments::useJavac, K2JVMCompilerArguments::useJavac,
K2JVMCompilerArguments::compileJava, K2JVMCompilerArguments::compileJava,