Inject JvmTarget into some JVM-specific call checkers
This makes it possible to drop CompilerConfiguration from CallCheckerContext, which in turn helps to avoid passing the entire CompilerConfiguration instance through front-end
This commit is contained in:
@@ -51,7 +51,7 @@ import org.jetbrains.kotlin.serialization.deserialization.MetadataPackageFragmen
|
||||
object DefaultAnalyzerFacade : AnalyzerFacade<PlatformAnalysisParameters>() {
|
||||
private val compilerConfiguration = CompilerConfiguration().apply {
|
||||
languageVersionSettings = LanguageVersionSettingsImpl(
|
||||
LanguageVersion.LATEST, ApiVersion.LATEST, setOf(LanguageFeature.MultiPlatformProjects)
|
||||
LanguageVersion.LATEST, ApiVersion.LATEST, additionalFeatures = setOf(LanguageFeature.MultiPlatformProjects)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ object DefaultAnalyzerFacade : AnalyzerFacade<PlatformAnalysisParameters>() {
|
||||
targetEnvironment: TargetEnvironment,
|
||||
packagePartProvider: PackagePartProvider
|
||||
): StorageComponentContainer = createContainer("ResolveCommonCode", targetPlatform) {
|
||||
configureModule(moduleContext, targetPlatform, bindingTrace)
|
||||
configureModule(moduleContext, targetPlatform, TargetPlatformVersion.NoVersion, bindingTrace)
|
||||
|
||||
useInstance(moduleContentScope)
|
||||
useInstance(LookupTracker.DO_NOTHING)
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.kotlin.frontend.di
|
||||
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.config.TargetPlatformVersion
|
||||
import org.jetbrains.kotlin.config.languageVersionSettings
|
||||
import org.jetbrains.kotlin.container.StorageComponentContainer
|
||||
import org.jetbrains.kotlin.container.get
|
||||
@@ -36,7 +37,9 @@ import org.jetbrains.kotlin.types.expressions.LocalClassDescriptorHolder
|
||||
import org.jetbrains.kotlin.types.expressions.LocalLazyDeclarationResolver
|
||||
|
||||
fun StorageComponentContainer.configureModule(
|
||||
moduleContext: ModuleContext, platform: TargetPlatform
|
||||
moduleContext: ModuleContext,
|
||||
platform: TargetPlatform,
|
||||
platformVersion: TargetPlatformVersion
|
||||
) {
|
||||
useInstance(moduleContext)
|
||||
useInstance(moduleContext.module)
|
||||
@@ -45,6 +48,7 @@ fun StorageComponentContainer.configureModule(
|
||||
useInstance(moduleContext.module.builtIns)
|
||||
|
||||
useInstance(platform)
|
||||
useInstance(platformVersion)
|
||||
|
||||
platform.platformConfigurator.configureModuleComponents(this)
|
||||
|
||||
@@ -60,9 +64,12 @@ private fun StorageComponentContainer.configurePlatformIndependentComponents() {
|
||||
}
|
||||
|
||||
fun StorageComponentContainer.configureModule(
|
||||
moduleContext: ModuleContext, platform: TargetPlatform, trace: BindingTrace
|
||||
moduleContext: ModuleContext,
|
||||
platform: TargetPlatform,
|
||||
platformVersion: TargetPlatformVersion,
|
||||
trace: BindingTrace
|
||||
) {
|
||||
configureModule(moduleContext, platform)
|
||||
configureModule(moduleContext, platform, platformVersion)
|
||||
useInstance(trace)
|
||||
}
|
||||
|
||||
@@ -76,9 +83,10 @@ fun createContainerForBodyResolve(
|
||||
bindingTrace: BindingTrace,
|
||||
platform: TargetPlatform,
|
||||
statementFilter: StatementFilter,
|
||||
targetPlatformVersion: TargetPlatformVersion,
|
||||
compilerConfiguration: CompilerConfiguration
|
||||
): StorageComponentContainer = createContainer("BodyResolve", platform) {
|
||||
configureModule(moduleContext, platform, bindingTrace)
|
||||
configureModule(moduleContext, platform, targetPlatformVersion, bindingTrace)
|
||||
|
||||
useInstance(statementFilter)
|
||||
|
||||
@@ -95,9 +103,10 @@ fun createContainerForLazyBodyResolve(
|
||||
bindingTrace: BindingTrace,
|
||||
platform: TargetPlatform,
|
||||
bodyResolveCache: BodyResolveCache,
|
||||
targetPlatformVersion: TargetPlatformVersion,
|
||||
compilerConfiguration: CompilerConfiguration
|
||||
): StorageComponentContainer = createContainer("LazyBodyResolve", platform) {
|
||||
configureModule(moduleContext, platform, bindingTrace)
|
||||
configureModule(moduleContext, platform, targetPlatformVersion, bindingTrace)
|
||||
|
||||
useInstance(LookupTracker.DO_NOTHING)
|
||||
useInstance(kotlinCodeAnalyzer)
|
||||
@@ -113,11 +122,12 @@ fun createContainerForLazyLocalClassifierAnalyzer(
|
||||
bindingTrace: BindingTrace,
|
||||
platform: TargetPlatform,
|
||||
lookupTracker: LookupTracker,
|
||||
targetPlatformVersion: TargetPlatformVersion,
|
||||
compilerConfiguration: CompilerConfiguration,
|
||||
statementFilter: StatementFilter,
|
||||
localClassDescriptorHolder: LocalClassDescriptorHolder
|
||||
): StorageComponentContainer = createContainer("LocalClassifierAnalyzer", platform) {
|
||||
configureModule(moduleContext, platform, bindingTrace)
|
||||
configureModule(moduleContext, platform, targetPlatformVersion, bindingTrace)
|
||||
|
||||
useInstance(localClassDescriptorHolder)
|
||||
useInstance(lookupTracker)
|
||||
@@ -142,10 +152,11 @@ fun createContainerForLazyResolve(
|
||||
declarationProviderFactory: DeclarationProviderFactory,
|
||||
bindingTrace: BindingTrace,
|
||||
platform: TargetPlatform,
|
||||
targetPlatformVersion: TargetPlatformVersion,
|
||||
targetEnvironment: TargetEnvironment,
|
||||
compilerConfiguration: CompilerConfiguration
|
||||
): StorageComponentContainer = createContainer("LazyResolve", platform) {
|
||||
configureModule(moduleContext, platform, bindingTrace)
|
||||
configureModule(moduleContext, platform, targetPlatformVersion, bindingTrace)
|
||||
|
||||
useInstance(declarationProviderFactory)
|
||||
useInstance(LookupTracker.DO_NOTHING)
|
||||
@@ -166,6 +177,7 @@ fun createLazyResolveSession(moduleContext: ModuleContext, files: Collection<KtF
|
||||
FileBasedDeclarationProviderFactory(moduleContext.storageManager, files),
|
||||
BindingTraceContext(),
|
||||
TargetPlatform.Default,
|
||||
TargetPlatformVersion.NoVersion,
|
||||
CompilerEnvironment,
|
||||
CompilerConfiguration.EMPTY
|
||||
).get<ResolveSession>()
|
||||
|
||||
+5
-3
@@ -20,6 +20,7 @@ import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.config.TargetPlatformVersion
|
||||
import org.jetbrains.kotlin.config.languageVersionSettings
|
||||
import org.jetbrains.kotlin.container.get
|
||||
import org.jetbrains.kotlin.context.GlobalContext
|
||||
@@ -62,6 +63,7 @@ class LocalClassifierAnalyzer(
|
||||
private val platform: TargetPlatform,
|
||||
private val lookupTracker: LookupTracker,
|
||||
private val supertypeLoopChecker: SupertypeLoopChecker,
|
||||
private val targetPlatformVersion: TargetPlatformVersion,
|
||||
private val compilerConfiguration: CompilerConfiguration,
|
||||
private val delegationFilter: DelegationFilter
|
||||
) {
|
||||
@@ -79,6 +81,7 @@ class LocalClassifierAnalyzer(
|
||||
context.trace,
|
||||
platform,
|
||||
lookupTracker,
|
||||
targetPlatformVersion,
|
||||
compilerConfiguration,
|
||||
context.statementFilter,
|
||||
LocalClassDescriptorHolder(
|
||||
@@ -160,10 +163,9 @@ class LocalClassDescriptorHolder(
|
||||
override val languageVersionSettings = this@LocalClassDescriptorHolder.languageVersionSettings
|
||||
override val syntheticResolveExtension = this@LocalClassDescriptorHolder.syntheticResolveExtension
|
||||
override val delegationFilter: DelegationFilter = this@LocalClassDescriptorHolder.delegationFilter
|
||||
}
|
||||
,
|
||||
},
|
||||
containingDeclaration,
|
||||
classOrObject.getNameAsSafeName(),
|
||||
classOrObject.nameAsSafeName,
|
||||
KtClassInfoUtil.createClassLikeInfo(classOrObject),
|
||||
classOrObject.hasModifier(KtTokens.EXTERNAL_KEYWORD)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user