[FE] Substitute fixed type variables with inferred stub types
Actually, a type variable might be fixed into a stub type. Such stub type should be substituted before sub calls completion ^KT-51988 Fixed
This commit is contained in:
committed by
teamcity
parent
92df5cd67f
commit
6027c2a9aa
@@ -97,7 +97,7 @@ class DelegateInferenceSession(
|
||||
|
||||
override fun inferPostponedVariables(
|
||||
lambda: ResolvedLambdaAtom,
|
||||
initialStorage: ConstraintStorage,
|
||||
constraintSystemBuilder: ConstraintSystemBuilder,
|
||||
completionMode: ConstraintSystemCompletionMode,
|
||||
diagnosticsHolder: KotlinDiagnosticsHolder
|
||||
): Map<TypeConstructor, UnwrappedType> = emptyMap()
|
||||
@@ -124,7 +124,7 @@ class InferenceSessionForExistingCandidates(
|
||||
override fun currentConstraintSystem(): ConstraintStorage = ConstraintStorage.Empty
|
||||
override fun inferPostponedVariables(
|
||||
lambda: ResolvedLambdaAtom,
|
||||
initialStorage: ConstraintStorage,
|
||||
constraintSystemBuilder: ConstraintSystemBuilder,
|
||||
completionMode: ConstraintSystemCompletionMode,
|
||||
diagnosticsHolder: KotlinDiagnosticsHolder
|
||||
): Map<TypeConstructor, UnwrappedType> = emptyMap()
|
||||
|
||||
+12
-5
@@ -233,22 +233,23 @@ class BuilderInferenceSession(
|
||||
|
||||
override fun inferPostponedVariables(
|
||||
lambda: ResolvedLambdaAtom,
|
||||
initialStorage: ConstraintStorage,
|
||||
constraintSystemBuilder: ConstraintSystemBuilder,
|
||||
completionMode: ConstraintSystemCompletionMode,
|
||||
diagnosticsHolder: KotlinDiagnosticsHolder,
|
||||
): Map<TypeConstructor, UnwrappedType>? {
|
||||
initializeLambda(lambda)
|
||||
|
||||
fun getResultingSubstitutor(): NewTypeSubstitutor {
|
||||
val initialStorage = constraintSystemBuilder.currentStorage()
|
||||
val resultingSubstitutor by lazy {
|
||||
val storageSubstitutor = initialStorage.buildResultingSubstitutor(commonSystem, transformTypeVariablesToErrorTypes = false)
|
||||
return ComposedSubstitutor(storageSubstitutor, commonSystem.buildCurrentSubstitutor() as NewTypeSubstitutor)
|
||||
ComposedSubstitutor(storageSubstitutor, commonSystem.buildCurrentSubstitutor() as NewTypeSubstitutor)
|
||||
}
|
||||
|
||||
val effectivelyEmptyConstraintSystem = initializeCommonSystem(initialStorage)
|
||||
|
||||
if (effectivelyEmptyConstraintSystem) {
|
||||
if (isTopLevelBuilderInferenceCall()) {
|
||||
updateAllCalls(getResultingSubstitutor())
|
||||
updateAllCalls(resultingSubstitutor)
|
||||
}
|
||||
return null
|
||||
}
|
||||
@@ -261,8 +262,14 @@ class BuilderInferenceSession(
|
||||
diagnosticsHolder
|
||||
)
|
||||
|
||||
if (completionMode == ConstraintSystemCompletionMode.FULL) {
|
||||
constraintSystemBuilder.substituteFixedVariables(
|
||||
ComposedSubstitutor(resultingSubstitutor, createNonFixedTypeToVariableSubstitutor())
|
||||
)
|
||||
}
|
||||
|
||||
if (isTopLevelBuilderInferenceCall()) {
|
||||
updateAllCalls(getResultingSubstitutor())
|
||||
updateAllCalls(resultingSubstitutor)
|
||||
}
|
||||
|
||||
return commonSystem.fixedTypeVariables.cast() // TODO: SUB
|
||||
|
||||
Reference in New Issue
Block a user