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:
+7
-19
@@ -41,7 +41,7 @@ class FirDelegatedPropertyInferenceSession(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun integrateResolvedCall(storage: ConstraintStorage) {
|
private fun integrateResolvedCall(storage: ConstraintStorage) {
|
||||||
registerSyntheticVariables(storage)
|
registerSyntheticVariables(storage)
|
||||||
val stubToTypeVariableSubstitutor = createToSyntheticTypeVariableSubstitutor()
|
val stubToTypeVariableSubstitutor = createToSyntheticTypeVariableSubstitutor()
|
||||||
integrateConstraints(
|
integrateConstraints(
|
||||||
@@ -233,9 +233,7 @@ class FirDelegatedPropertyInferenceSession(
|
|||||||
.replaceStubsAndTypeVariablesToErrors(typeContext, stubTypesByTypeVariable.values.map { it.constructor })
|
.replaceStubsAndTypeVariablesToErrors(typeContext, stubTypesByTypeVariable.values.map { it.constructor })
|
||||||
}
|
}
|
||||||
|
|
||||||
val stubTypesByTypeVariable: MutableMap<ConeTypeVariable, ConeStubType> = mutableMapOf()
|
private val stubTypesByTypeVariable: MutableMap<ConeTypeVariable, ConeStubType> = mutableMapOf()
|
||||||
val stubTypeBySyntheticTypeVariable: MutableMap<ConeTypeVariable, ConeStubType> = mutableMapOf()
|
|
||||||
|
|
||||||
private val syntheticTypeVariableByTypeVariable = mutableMapOf<TypeVariableMarker, ConeTypeVariable>()
|
private val syntheticTypeVariableByTypeVariable = mutableMapOf<TypeVariableMarker, ConeTypeVariable>()
|
||||||
|
|
||||||
private fun registerSyntheticVariables(storage: ConstraintStorage) {
|
private fun registerSyntheticVariables(storage: ConstraintStorage) {
|
||||||
@@ -252,9 +250,7 @@ class FirDelegatedPropertyInferenceSession(
|
|||||||
ConeStubTypeForChainInference(
|
ConeStubTypeForChainInference(
|
||||||
syntheticVariable,
|
syntheticVariable,
|
||||||
ConeNullability.create(syntheticVariable.defaultType.isMarkedNullable)
|
ConeNullability.create(syntheticVariable.defaultType.isMarkedNullable)
|
||||||
).also {
|
)
|
||||||
stubTypeBySyntheticTypeVariable[syntheticVariable] = it
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -283,7 +279,7 @@ class FirDelegatedPropertyInferenceSession(
|
|||||||
storage: ConstraintStorage,
|
storage: ConstraintStorage,
|
||||||
nonFixedToVariablesSubstitutor: ConeSubstitutor,
|
nonFixedToVariablesSubstitutor: ConeSubstitutor,
|
||||||
shouldIntegrateAllConstraints: Boolean
|
shouldIntegrateAllConstraints: Boolean
|
||||||
): Boolean {
|
) {
|
||||||
if (shouldIntegrateAllConstraints) {
|
if (shouldIntegrateAllConstraints) {
|
||||||
storage.notFixedTypeVariables.values.forEach {
|
storage.notFixedTypeVariables.values.forEach {
|
||||||
if (isSyntheticTypeVariable(it.typeVariable)) return@forEach
|
if (isSyntheticTypeVariable(it.typeVariable)) return@forEach
|
||||||
@@ -300,15 +296,10 @@ class FirDelegatedPropertyInferenceSession(
|
|||||||
val callSubstitutor =
|
val callSubstitutor =
|
||||||
storage.buildAbstractResultingSubstitutor(commonSystem, transformTypeVariablesToErrorTypes = false) as ConeSubstitutor
|
storage.buildAbstractResultingSubstitutor(commonSystem, transformTypeVariablesToErrorTypes = false) as ConeSubstitutor
|
||||||
|
|
||||||
var introducedConstraint = false
|
|
||||||
|
|
||||||
for (initialConstraint in storage.initialConstraints) {
|
for (initialConstraint in storage.initialConstraints) {
|
||||||
if (integrateConstraintToSystem(
|
integrateConstraintToSystem(
|
||||||
commonSystem, initialConstraint, callSubstitutor, nonFixedToVariablesSubstitutor, storage.fixedTypeVariables
|
commonSystem, initialConstraint, callSubstitutor, nonFixedToVariablesSubstitutor, storage.fixedTypeVariables
|
||||||
)
|
)
|
||||||
) {
|
|
||||||
introducedConstraint = true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shouldIntegrateAllConstraints) {
|
if (shouldIntegrateAllConstraints) {
|
||||||
@@ -318,10 +309,7 @@ class FirDelegatedPropertyInferenceSession(
|
|||||||
|
|
||||||
commonSystem.registerTypeVariableIfNotPresent(typeVariable)
|
commonSystem.registerTypeVariableIfNotPresent(typeVariable)
|
||||||
commonSystem.addEqualityConstraint((typeVariable as ConeTypeVariable).defaultType, type, BuilderInferencePosition)
|
commonSystem.addEqualityConstraint((typeVariable as ConeTypeVariable).defaultType, type, BuilderInferencePosition)
|
||||||
introducedConstraint = true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return introducedConstraint
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user