[FIR] Remove way to create FirSession using Module

The problem is that Module may not contain some default dependencies in
  classpath roots, so it's incorrect to take them from it
This commit is contained in:
Dmitriy Novozhilov
2021-05-19 13:38:33 +03:00
committed by TeamCityServer
parent b2ef854aa1
commit 2ee54c2201
5 changed files with 22 additions and 1 deletions
@@ -66,6 +66,7 @@ import org.jetbrains.kotlin.load.kotlin.incremental.IncrementalPackagePartProvid
import org.jetbrains.kotlin.modules.Module import org.jetbrains.kotlin.modules.Module
import org.jetbrains.kotlin.modules.TargetId import org.jetbrains.kotlin.modules.TargetId
import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus
import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.KtFile
@@ -339,7 +340,7 @@ object KotlinToJVMBytecodeCompiler {
val languageVersionSettings = moduleConfiguration.languageVersionSettings val languageVersionSettings = moduleConfiguration.languageVersionSettings
val session = createSessionWithDependencies( val session = createSessionWithDependencies(
module, Name.identifier(module.getModuleName()),
JvmPlatforms.unspecifiedJvmPlatform, JvmPlatforms.unspecifiedJvmPlatform,
JvmPlatformAnalyzerServices, JvmPlatformAnalyzerServices,
externalSessionProvider = null, externalSessionProvider = null,
@@ -357,6 +358,10 @@ object KotlinToJVMBytecodeCompiler {
) )
FirSessionFactory.ProviderAndScopeForIncrementalCompilation(packagePartProvider, librariesScope) FirSessionFactory.ProviderAndScopeForIncrementalCompilation(packagePartProvider, librariesScope)
}, },
dependenciesConfigurator = {
dependencies(moduleConfiguration.jvmClasspathRoots.map { it.toPath() })
friendDependencies(moduleConfiguration[JVMConfigurationKeys.FRIEND_PATHS] ?: emptyList())
},
sessionConfigurator = { sessionConfigurator = {
if (extendedAnalysisMode) { if (extendedAnalysisMode) {
registerExtendedCommonCheckers() registerExtendedCommonCheckers()
+6
View File
@@ -0,0 +1,6 @@
$TESTDATA_DIR$/firStdlibDependency.kt
-Xuse-fir
-cp
.
-d
$TEMP_DIR$
+1
View File
@@ -0,0 +1 @@
fun main() = println("hello")
+4
View File
@@ -0,0 +1,4 @@
warning: ATTENTION!
This build uses in-dev FIR:
-Xuse-fir
OK
@@ -316,6 +316,11 @@ public class CliTestGenerated extends AbstractCliTest {
runTest("compiler/testData/cli/jvm/firHello.args"); runTest("compiler/testData/cli/jvm/firHello.args");
} }
@TestMetadata("firStdlibDependency.args")
public void testFirStdlibDependency() throws Exception {
runTest("compiler/testData/cli/jvm/firStdlibDependency.args");
}
@TestMetadata("flagAllowingResultAsReturnType.args") @TestMetadata("flagAllowingResultAsReturnType.args")
public void testFlagAllowingResultAsReturnType() throws Exception { public void testFlagAllowingResultAsReturnType() throws Exception {
runTest("compiler/testData/cli/jvm/flagAllowingResultAsReturnType.args"); runTest("compiler/testData/cli/jvm/flagAllowingResultAsReturnType.args");