Add util for safe registration of type variables in constraint system

This commit is contained in:
Simon Ogorodnik
2021-12-13 12:55:49 +03:00
committed by teamcity
parent d084cfb65b
commit 8cf97127fe
3 changed files with 12 additions and 7 deletions
@@ -6,6 +6,7 @@
package org.jetbrains.kotlin.resolve.calls.inference
import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintStorage
import org.jetbrains.kotlin.resolve.calls.inference.model.NewConstraintSystemImpl
import org.jetbrains.kotlin.types.model.*
fun ConstraintStorage.buildCurrentSubstitutor(
@@ -71,3 +72,12 @@ fun TypeSystemInferenceExtensionContext.extractTypeForGivenRecursiveTypeParamete
return null
}
fun NewConstraintSystemImpl.registerTypeVariableIfNotPresent(
typeVariable: TypeVariableMarker
) {
val builder = getBuilder()
if (typeVariable.freshTypeConstructor(this) !in builder.currentStorage().allTypeVariables.keys) {
builder.registerVariable(typeVariable)
}
}