diff --git a/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/session/ComponentsContainers.kt b/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/session/ComponentsContainers.kt index f381eeec1c7..32fa7442246 100644 --- a/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/session/ComponentsContainers.kt +++ b/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/session/ComponentsContainers.kt @@ -34,6 +34,7 @@ fun FirSession.registerCommonComponents() { register(FirRegisteredPluginAnnotations::class, FirRegisteredPluginAnnotations.create(this)) register(FirPredicateBasedProvider::class, FirPredicateBasedProvider.create(this)) register(GeneratedClassIndex::class, GeneratedClassIndex.create()) + register(FirLanguageSettingsComponent::class, FirLanguageSettingsComponent(this)) register(InferenceComponents::class, InferenceComponents(this)) } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirLanguageSettingsComponent.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirLanguageSettingsComponent.kt new file mode 100644 index 00000000000..413f8fac8c1 --- /dev/null +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirLanguageSettingsComponent.kt @@ -0,0 +1,20 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir + +import org.jetbrains.kotlin.config.LanguageVersionSettings +import org.jetbrains.kotlin.config.LanguageVersionSettingsImpl + +@NoMutableState +class FirLanguageSettingsComponent(val session: FirSession) : FirSessionComponent { + val languageVersionSettings: LanguageVersionSettings = + LanguageVersionSettingsImpl.DEFAULT // TODO +} + +val FirSession.languageSettingsComponent: FirLanguageSettingsComponent by FirSession.sessionComponentAccessor() + +val FirSession.languageVersionSettings: LanguageVersionSettings + get() = languageSettingsComponent.languageVersionSettings diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/ConstraintSystemCompleter.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/ConstraintSystemCompleter.kt index 521be758bb3..2aa4bd313ef 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/ConstraintSystemCompleter.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/ConstraintSystemCompleter.kt @@ -30,10 +30,8 @@ import org.jetbrains.kotlin.utils.addIfNotNull import org.jetbrains.kotlin.utils.addToStdlib.safeAs class ConstraintSystemCompleter(private val components: BodyResolveComponents) { - private val inferenceComponents - get() = components.session.inferenceComponents - val variableFixationFinder - get() = inferenceComponents.variableFixationFinder + private val inferenceComponents = components.session.inferenceComponents + val variableFixationFinder = inferenceComponents.variableFixationFinder fun complete( c: ConstraintSystemCompletionContext, diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/InferenceComponents.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/InferenceComponents.kt index cda54abaf28..8840235b13d 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/InferenceComponents.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/InferenceComponents.kt @@ -5,11 +5,7 @@ package org.jetbrains.kotlin.fir.resolve.inference -import org.jetbrains.kotlin.config.LanguageVersionSettings -import org.jetbrains.kotlin.config.LanguageVersionSettingsImpl -import org.jetbrains.kotlin.fir.FirSession -import org.jetbrains.kotlin.fir.FirSessionComponent -import org.jetbrains.kotlin.fir.NoMutableState +import org.jetbrains.kotlin.fir.* import org.jetbrains.kotlin.fir.types.ConeInferenceContext import org.jetbrains.kotlin.fir.types.ConeTypeCheckerContext import org.jetbrains.kotlin.resolve.calls.inference.components.* @@ -19,7 +15,6 @@ import org.jetbrains.kotlin.types.AbstractTypeApproximator @NoMutableState class InferenceComponents(val session: FirSession) : FirSessionComponent { val ctx: ConeTypeCheckerContext = ConeTypeCheckerContext(isErrorTypeEqualsToAnything = false, isStubTypeEqualsToAnything = false, session) - val languageVersionSettings: LanguageVersionSettings = LanguageVersionSettingsImpl.DEFAULT // TODO val approximator: AbstractTypeApproximator = object : AbstractTypeApproximator(ctx) {} val trivialConstraintTypeInferenceOracle = TrivialConstraintTypeInferenceOracle.create(ctx) @@ -27,13 +22,13 @@ class InferenceComponents(val session: FirSession) : FirSessionComponent { private val injector = ConstraintInjector( incorporator, approximator, - languageVersionSettings, + session.languageVersionSettings, ) val resultTypeResolver = ResultTypeResolver(approximator, trivialConstraintTypeInferenceOracle) val constraintSystemFactory = ConstraintSystemFactory() - val variableFixationFinder = VariableFixationFinder(trivialConstraintTypeInferenceOracle, languageVersionSettings) + val variableFixationFinder = VariableFixationFinder(trivialConstraintTypeInferenceOracle, session.languageVersionSettings) fun createConstraintSystem(): NewConstraintSystemImpl { return NewConstraintSystemImpl(injector, ctx)