Changes in the compiler needed to run KAPT 4 (KT-51982)
This commit is contained in:
committed by
Space Team
parent
dac8688a29
commit
84bf411cc3
@@ -77,9 +77,7 @@ private fun switchToFallbackModeIfNecessary(arguments: CommonCompilerArguments,
|
||||
arguments.skipPrereleaseCheck = true
|
||||
arguments.allowUnstableDependencies = true
|
||||
}
|
||||
isK2 && isKaptUsed && arguments.useKapt4 -> warn("Kapt 4 is still experimental. Use with caution.")
|
||||
arguments.useKapt4 && !isK2 -> warn("-Xuse-kapt4 flag can be only used with language version 2.0+.")
|
||||
arguments.useKapt4 && !isKaptUsed -> warn("-Xuse-kapt4 flag is present but no Kapt configuration options are provided.")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -142,7 +142,7 @@ class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
|
||||
val targetDescription = chunk.map { input -> input.getModuleName() + "-" + input.getModuleType() }.let { names ->
|
||||
names.singleOrNull() ?: names.joinToString()
|
||||
}
|
||||
if (configuration.getBoolean(CommonConfigurationKeys.USE_FIR) && configuration.getBoolean(CommonConfigurationKeys.USE_LIGHT_TREE)) {
|
||||
if (configuration.getBoolean(CommonConfigurationKeys.USE_FIR) && configuration.getBoolean(CommonConfigurationKeys.USE_LIGHT_TREE)) {
|
||||
val projectEnvironment =
|
||||
createProjectEnvironment(configuration, rootDisposable, EnvironmentConfigFiles.JVM_CONFIG_FILES, messageCollector)
|
||||
|
||||
|
||||
+5
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.fir.backend.*
|
||||
import org.jetbrains.kotlin.fir.backend.jvm.*
|
||||
import org.jetbrains.kotlin.fir.declarations.FirFile
|
||||
import org.jetbrains.kotlin.fir.declarations.FirSimpleFunction
|
||||
import org.jetbrains.kotlin.fir.extensions.FirAnalysisHandlerExtension
|
||||
import org.jetbrains.kotlin.fir.extensions.FirExtensionRegistrar
|
||||
import org.jetbrains.kotlin.fir.pipeline.*
|
||||
import org.jetbrains.kotlin.fir.session.*
|
||||
@@ -90,6 +91,10 @@ object FirKotlinToJvmBytecodeCompiler {
|
||||
|
||||
// TODO: run lowerings for all modules in the chunk, then run codegen for all modules.
|
||||
val project = (projectEnvironment as? VfsBasedProjectEnvironment)?.project
|
||||
if (project != null) {
|
||||
FirAnalysisHandlerExtension.analyze(project, projectConfiguration)?.let { return it }
|
||||
}
|
||||
|
||||
for (module in chunk) {
|
||||
val moduleConfiguration = projectConfiguration.applyModuleProperties(module, buildFile)
|
||||
val context = CompilationContext(
|
||||
|
||||
@@ -47,6 +47,7 @@ import org.jetbrains.kotlin.fir.backend.Fir2IrConfiguration
|
||||
import org.jetbrains.kotlin.fir.backend.jvm.FirJvmBackendClassResolver
|
||||
import org.jetbrains.kotlin.fir.backend.jvm.FirJvmBackendExtension
|
||||
import org.jetbrains.kotlin.fir.backend.jvm.JvmFir2IrExtensions
|
||||
import org.jetbrains.kotlin.fir.extensions.FirAnalysisHandlerExtension
|
||||
import org.jetbrains.kotlin.fir.extensions.FirExtensionRegistrar
|
||||
import org.jetbrains.kotlin.fir.pipeline.FirResult
|
||||
import org.jetbrains.kotlin.fir.pipeline.buildResolveAndCheckFirViaLightTree
|
||||
@@ -87,6 +88,9 @@ fun compileModulesUsingFrontendIrAndLightTree(
|
||||
|
||||
performanceManager?.notifyCompilerInitialized(0, 0, targetDescription)
|
||||
|
||||
val project = projectEnvironment.project
|
||||
FirAnalysisHandlerExtension.analyze(project, compilerConfiguration)?.let { return it }
|
||||
|
||||
val outputs = mutableListOf<GenerationState>()
|
||||
var mainClassFqName: FqName? = null
|
||||
|
||||
@@ -509,7 +513,7 @@ private fun VirtualFileSystem.findJarRoot(file: File): VirtualFile? =
|
||||
findFileByPath("$file${URLUtil.JAR_SEPARATOR}")
|
||||
|
||||
private fun VirtualFileSystem.findExistingRoot(
|
||||
root: JvmContentRoot, rootDescription: String, messageCollector: MessageCollector
|
||||
root: JvmContentRoot, rootDescription: String, messageCollector: MessageCollector,
|
||||
): VirtualFile? {
|
||||
return findFileByPath(root.file.absolutePath).also {
|
||||
if (it == null) {
|
||||
|
||||
Reference in New Issue
Block a user