Minor. Cleanup FirDelegatedPropertyInferenceSession a bit

- Some functions might be private
- the stubTypeBySyntheticTypeVariable map is actually write-only
- integrateConstraints Boolean return value is always unused
This commit is contained in:
Denis.Zharkov
2023-04-21 13:00:54 +02:00
parent f425dea3b8
commit 8b81c3715d
@@ -41,7 +41,7 @@ class FirDelegatedPropertyInferenceSession(
}
}
fun integrateResolvedCall(storage: ConstraintStorage) {
private fun integrateResolvedCall(storage: ConstraintStorage) {
registerSyntheticVariables(storage)
val stubToTypeVariableSubstitutor = createToSyntheticTypeVariableSubstitutor()
integrateConstraints(
@@ -233,9 +233,7 @@ class FirDelegatedPropertyInferenceSession(
.replaceStubsAndTypeVariablesToErrors(typeContext, stubTypesByTypeVariable.values.map { it.constructor })
}
val stubTypesByTypeVariable: MutableMap<ConeTypeVariable, ConeStubType> = mutableMapOf()
val stubTypeBySyntheticTypeVariable: MutableMap<ConeTypeVariable, ConeStubType> = mutableMapOf()
private val stubTypesByTypeVariable: MutableMap<ConeTypeVariable, ConeStubType> = mutableMapOf()
private val syntheticTypeVariableByTypeVariable = mutableMapOf<TypeVariableMarker, ConeTypeVariable>()
private fun registerSyntheticVariables(storage: ConstraintStorage) {
@@ -252,9 +250,7 @@ class FirDelegatedPropertyInferenceSession(
ConeStubTypeForChainInference(
syntheticVariable,
ConeNullability.create(syntheticVariable.defaultType.isMarkedNullable)
).also {
stubTypeBySyntheticTypeVariable[syntheticVariable] = it
}
)
}
}
}
@@ -283,7 +279,7 @@ class FirDelegatedPropertyInferenceSession(
storage: ConstraintStorage,
nonFixedToVariablesSubstitutor: ConeSubstitutor,
shouldIntegrateAllConstraints: Boolean
): Boolean {
) {
if (shouldIntegrateAllConstraints) {
storage.notFixedTypeVariables.values.forEach {
if (isSyntheticTypeVariable(it.typeVariable)) return@forEach
@@ -300,15 +296,10 @@ class FirDelegatedPropertyInferenceSession(
val callSubstitutor =
storage.buildAbstractResultingSubstitutor(commonSystem, transformTypeVariablesToErrorTypes = false) as ConeSubstitutor
var introducedConstraint = false
for (initialConstraint in storage.initialConstraints) {
if (integrateConstraintToSystem(
commonSystem, initialConstraint, callSubstitutor, nonFixedToVariablesSubstitutor, storage.fixedTypeVariables
)
) {
introducedConstraint = true
}
integrateConstraintToSystem(
commonSystem, initialConstraint, callSubstitutor, nonFixedToVariablesSubstitutor, storage.fixedTypeVariables
)
}
if (shouldIntegrateAllConstraints) {
@@ -318,10 +309,7 @@ class FirDelegatedPropertyInferenceSession(
commonSystem.registerTypeVariableIfNotPresent(typeVariable)
commonSystem.addEqualityConstraint((typeVariable as ConeTypeVariable).defaultType, type, BuilderInferencePosition)
introducedConstraint = true
}
}
return introducedConstraint
}
}