Introduce specific error for calls which could be resolved only with unrestricted builder inference

^KT-47747 Fixed
This commit is contained in:
Victor Petukhov
2021-07-15 12:57:31 +03:00
committed by teamcityserver
parent 357fda2efa
commit 6a1ec92d39
15 changed files with 38 additions and 11 deletions
@@ -15,6 +15,7 @@ interface ConstraintSystemOperation {
val hasContradiction: Boolean
fun registerVariable(variable: TypeVariableMarker)
fun markPostponedVariable(variable: TypeVariableMarker)
fun markCouldBeResolvedWithUnrestrictedBuilderInference()
fun unmarkPostponedVariable(variable: TypeVariableMarker)
fun removePostponedVariables()
@@ -32,4 +32,6 @@ interface ConstraintSystemCompletionContext : VariableFixationFinder.Context, Re
fun fixVariable(variable: TypeVariableMarker, resultType: KotlinTypeMarker, position: FixVariableConstraintPosition<*>)
fun asConstraintSystemCompletionContext(): ConstraintSystemCompletionContext
fun couldBeResolvedWithUnrestrictedBuilderInference(): Boolean
}
@@ -118,7 +118,8 @@ class CapturedTypeFromSubtyping(
open class NotEnoughInformationForTypeParameter<T>(
val typeVariable: TypeVariableMarker,
val resolvedAtom: T
val resolvedAtom: T,
val couldBeResolvedWithUnrestrictedBuilderInference: Boolean
) : ConstraintSystemError(INAPPLICABLE)
class ConstrainingTypeIsError(
@@ -38,6 +38,8 @@ class NewConstraintSystemImpl(
private val properTypesCache: MutableSet<KotlinTypeMarker> = SmartSet.create()
private val notProperTypesCache: MutableSet<KotlinTypeMarker> = SmartSet.create()
private var couldBeResolvedWithUnrestrictedBuilderInference: Boolean = false
private enum class State {
BUILDING,
TRANSACTION,
@@ -118,6 +120,13 @@ class NewConstraintSystemImpl(
storage.postponedTypeVariables += variable
}
override fun markCouldBeResolvedWithUnrestrictedBuilderInference() {
couldBeResolvedWithUnrestrictedBuilderInference = true
}
override fun couldBeResolvedWithUnrestrictedBuilderInference() =
couldBeResolvedWithUnrestrictedBuilderInference
override fun unmarkPostponedVariable(variable: TypeVariableMarker) {
storage.postponedTypeVariables -= variable
}