Dont store type refinement mode in analysis flags
Instead, check the refiner from the DI-container or refiner from capability of a module descriptor. The reason is because in the IDE there might be multiple ResolutionFacades (-> multiple DI-containers -> multiple module descriptors) for one and the same IDE module, with different refinement settings. However, due to how the code is written, it's hard to have different LanguageVersionSettings for one and the same module. After this commit the refinement settings are determined by the moduleDescriptor capabilities, which is much easier to tweak See usage of that change in Kotlin IDE Plugin (commit is linked to the YT issue) ^KTIJ-20775
This commit is contained in:
@@ -36,9 +36,6 @@ object AnalysisFlags {
|
||||
@JvmStatic
|
||||
val constraintSystemForOverloadResolution by AnalysisFlag.Delegates.ConstraintSystemForOverloadResolution
|
||||
|
||||
@JvmStatic
|
||||
val useTypeRefinement by AnalysisFlag.Delegates.Boolean
|
||||
|
||||
@JvmStatic
|
||||
val ideMode by AnalysisFlag.Delegates.Boolean
|
||||
|
||||
|
||||
@@ -76,8 +76,5 @@ var CompilerConfiguration.languageVersionSettings: LanguageVersionSettings
|
||||
get() = get(CommonConfigurationKeys.LANGUAGE_VERSION_SETTINGS, LanguageVersionSettingsImpl.DEFAULT)
|
||||
set(value) = put(CommonConfigurationKeys.LANGUAGE_VERSION_SETTINGS, value)
|
||||
|
||||
val LanguageVersionSettings.isTypeRefinementEnabled: Boolean
|
||||
get() = getFlag(AnalysisFlags.useTypeRefinement)
|
||||
|
||||
val LanguageVersionSettings.isLibraryToSourceAnalysisEnabled: Boolean
|
||||
get() = getFlag(AnalysisFlags.libraryToSourceAnalysis)
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.jetbrains.kotlin.frontend.di
|
||||
|
||||
import org.jetbrains.kotlin.cfg.ControlFlowInformationProvider
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.config.isTypeRefinementEnabled
|
||||
import org.jetbrains.kotlin.container.StorageComponentContainer
|
||||
import org.jetbrains.kotlin.container.useImpl
|
||||
import org.jetbrains.kotlin.container.useInstance
|
||||
@@ -40,6 +39,7 @@ import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactoryImpl
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.KotlinResolutionStatelessCallbacksImpl
|
||||
import org.jetbrains.kotlin.resolve.checkers.ExpectedActualDeclarationChecker
|
||||
import org.jetbrains.kotlin.resolve.checkers.ExperimentalUsageChecker
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.isTypeRefinementEnabled
|
||||
import org.jetbrains.kotlin.resolve.lazy.*
|
||||
import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProviderFactory
|
||||
import org.jetbrains.kotlin.types.KotlinTypeRefinerImpl
|
||||
@@ -88,7 +88,7 @@ fun StorageComponentContainer.configureModule(
|
||||
|
||||
useImpl<NewKotlinTypeCheckerImpl>()
|
||||
|
||||
if (languageVersionSettings.isTypeRefinementEnabled) {
|
||||
if (moduleContext.module.isTypeRefinementEnabled()) {
|
||||
useImpl<KotlinTypeRefinerImpl>()
|
||||
} else {
|
||||
useInstance(KotlinTypeRefiner.Default)
|
||||
|
||||
+1
-2
@@ -17,7 +17,6 @@
|
||||
package org.jetbrains.kotlin.js.resolve.diagnostics
|
||||
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.config.isTypeRefinementEnabled
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
@@ -119,7 +118,7 @@ class JsNameClashChecker(
|
||||
existing: CallableMemberDescriptor,
|
||||
overrideDescriptor: CallableMemberDescriptor
|
||||
): Boolean {
|
||||
return if (!languageVersionSettings.isTypeRefinementEnabled) {
|
||||
return if (kotlinTypeRefiner === KotlinTypeRefiner.Default) {
|
||||
// Fast-path
|
||||
existing == overrideDescriptor
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user