FIR: Fix synthetic type variables to independent stub types
This commit is contained in:
committed by
teamcity
parent
580410863f
commit
df9da371cb
+15
-9
@@ -226,15 +226,21 @@ class ConstraintSystemCompleter(private val components: BodyResolveComponents, p
|
||||
|
||||
val variableWithConstraints = notFixedTypeVariables.getValue(variableForFixation.variable)
|
||||
|
||||
if (variableForFixation.hasProperConstraint) {
|
||||
fixVariable(asConstraintSystemCompletionContext(), topLevelType, variableWithConstraints, postponedArguments)
|
||||
return true
|
||||
} else if (context.inferenceSession.isSyntheticTypeVariable(variableWithConstraints.typeVariable)) {
|
||||
val variable = variableWithConstraints.typeVariable as ConeTypeVariable
|
||||
context.inferenceSession.fixSyntheticTypeVariableWithNotEnoughInformation(variable, asConstraintSystemCompletionContext())
|
||||
return true
|
||||
} else {
|
||||
processVariableWhenNotEnoughInformation(this, variableWithConstraints, topLevelAtoms)
|
||||
when {
|
||||
variableForFixation.hasProperConstraint -> {
|
||||
fixVariable(asConstraintSystemCompletionContext(), topLevelType, variableWithConstraints, postponedArguments)
|
||||
return true
|
||||
}
|
||||
context.inferenceSession.isSyntheticTypeVariable(variableWithConstraints.typeVariable) -> {
|
||||
context.inferenceSession.fixSyntheticTypeVariableWithNotEnoughInformation(
|
||||
variableWithConstraints.typeVariable as ConeTypeVariable,
|
||||
asConstraintSystemCompletionContext()
|
||||
)
|
||||
return true
|
||||
}
|
||||
else -> {
|
||||
processVariableWhenNotEnoughInformation(this, variableWithConstraints, topLevelAtoms)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+10
-5
@@ -112,15 +112,16 @@ class FirDelegatedPropertyInferenceSession(
|
||||
private fun createNonFixedTypeToVariableSubstitutor(): ConeSubstitutor {
|
||||
val typeContext = components.session.typeContext
|
||||
|
||||
val bindings = mutableMapOf<TypeConstructorMarker, ConeKotlinType>()
|
||||
for ((variable, stubType) in stubTypesByTypeVariable) {
|
||||
bindings[stubType.constructor] = variable.defaultType(typeContext) as ConeKotlinType
|
||||
val bindings = mutableMapOf<TypeVariableMarker, ConeKotlinType>()
|
||||
for ((variable, synthetic) in syntheticTypeVariableByTypeVariable) {
|
||||
bindings[synthetic] = variable.defaultType(typeContext) as ConeKotlinType
|
||||
}
|
||||
|
||||
return object : AbstractConeSubstitutor(typeContext) {
|
||||
override fun substituteType(type: ConeKotlinType): ConeKotlinType? {
|
||||
if (type !is ConeStubType) return null
|
||||
return bindings[type.constructor].updateNullabilityIfNeeded(type)
|
||||
if (type.constructor.isTypeVariableInSubtyping) return null
|
||||
return bindings[type.constructor.variable].updateNullabilityIfNeeded(type)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -151,9 +152,13 @@ class FirDelegatedPropertyInferenceSession(
|
||||
typeVariable: TypeVariableMarker,
|
||||
completionContext: ConstraintSystemCompletionContext
|
||||
) {
|
||||
typeVariable as ConeTypeVariable
|
||||
completionContext.fixVariable(
|
||||
typeVariable,
|
||||
stubTypeBySyntheticTypeVariable[typeVariable]!!,
|
||||
ConeStubTypeForFixation(
|
||||
ConeStubTypeConstructor(typeVariable, isTypeVariableInSubtyping = false, isForFixation = true),
|
||||
ConeNullability.create(typeVariable.defaultType.isMarkedNullable)
|
||||
),
|
||||
ConeFixVariableConstraintPosition(typeVariable)
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user