Add util for safe registration of type variables in constraint system
This commit is contained in:
committed by
teamcity
parent
d084cfb65b
commit
8cf97127fe
+1
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.buildAbstractResultingSubstitutor
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.components.ConstraintSystemCompletionMode
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.*
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.registerTypeVariableIfNotPresent
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.BUILDER_INFERENCE_ANNOTATION_FQ_NAME
|
||||
import org.jetbrains.kotlin.types.model.TypeConstructorMarker
|
||||
import org.jetbrains.kotlin.types.model.TypeSubstitutorMarker
|
||||
|
||||
+1
-7
@@ -19,6 +19,7 @@ import org.jetbrains.kotlin.resolve.calls.inference.buildAbstractResultingSubsti
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.components.ConstraintSystemCompletionContext
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.components.ConstraintSystemCompletionMode
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.*
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.registerTypeVariableIfNotPresent
|
||||
import org.jetbrains.kotlin.types.model.*
|
||||
|
||||
class FirDelegatedPropertyInferenceSession(
|
||||
@@ -337,11 +338,4 @@ class FirDelegatedPropertyInferenceSession(
|
||||
|
||||
return introducedConstraint
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun NewConstraintSystemImpl.registerTypeVariableIfNotPresent(typeVariable: TypeVariableMarker) {
|
||||
if (typeVariable.freshTypeConstructor(typeSystemContext) !in allTypeVariables) {
|
||||
registerVariable(typeVariable)
|
||||
}
|
||||
}
|
||||
+10
@@ -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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user