[FIR] Extract language settings into a dedicated component
^KT-42080 Fixed
This commit is contained in:
@@ -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))
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
+2
-4
@@ -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,
|
||||
|
||||
+3
-8
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user