Refactor. Remove ConstraintPosition data duplication
This commit is contained in:
committed by
teamcity
parent
4d9e919f7e
commit
91b629d16a
+2
-2
@@ -43,7 +43,7 @@ class ConstraintInjector(
|
|||||||
|
|
||||||
fun addInitialSubtypeConstraint(c: Context, lowerType: KotlinTypeMarker, upperType: KotlinTypeMarker, position: ConstraintPosition) {
|
fun addInitialSubtypeConstraint(c: Context, lowerType: KotlinTypeMarker, upperType: KotlinTypeMarker, position: ConstraintPosition) {
|
||||||
val initialConstraint = InitialConstraint(lowerType, upperType, UPPER, position).also { c.addInitialConstraint(it) }
|
val initialConstraint = InitialConstraint(lowerType, upperType, UPPER, position).also { c.addInitialConstraint(it) }
|
||||||
val typeCheckerState = TypeCheckerStateForConstraintInjector(c, IncorporationConstraintPosition(position, initialConstraint))
|
val typeCheckerState = TypeCheckerStateForConstraintInjector(c, IncorporationConstraintPosition(initialConstraint))
|
||||||
|
|
||||||
updateAllowedTypeDepth(c, lowerType)
|
updateAllowedTypeDepth(c, lowerType)
|
||||||
updateAllowedTypeDepth(c, upperType)
|
updateAllowedTypeDepth(c, upperType)
|
||||||
@@ -69,7 +69,7 @@ class ConstraintInjector(
|
|||||||
else -> return
|
else -> return
|
||||||
}
|
}
|
||||||
val initialConstraint = InitialConstraint(typeVariable, equalType, EQUALITY, position).also { c.addInitialConstraint(it) }
|
val initialConstraint = InitialConstraint(typeVariable, equalType, EQUALITY, position).also { c.addInitialConstraint(it) }
|
||||||
val typeCheckerState = TypeCheckerStateForConstraintInjector(c, IncorporationConstraintPosition(position, initialConstraint))
|
val typeCheckerState = TypeCheckerStateForConstraintInjector(c, IncorporationConstraintPosition(initialConstraint))
|
||||||
|
|
||||||
// We add constraints like `T? == Foo!` in the old way
|
// We add constraints like `T? == Foo!` in the old way
|
||||||
if (!typeVariable.isSimpleType() || typeVariable.isMarkedNullable()) {
|
if (!typeVariable.isSimpleType() || typeVariable.isMarkedNullable()) {
|
||||||
|
|||||||
+2
-1
@@ -77,10 +77,11 @@ open class DelegatedPropertyConstraintPosition<T>(val topLevelCall: T) : Constra
|
|||||||
}
|
}
|
||||||
|
|
||||||
data class IncorporationConstraintPosition(
|
data class IncorporationConstraintPosition(
|
||||||
val from: ConstraintPosition,
|
|
||||||
val initialConstraint: InitialConstraint,
|
val initialConstraint: InitialConstraint,
|
||||||
var isFromDeclaredUpperBound: Boolean = false
|
var isFromDeclaredUpperBound: Boolean = false
|
||||||
) : ConstraintPosition() {
|
) : ConstraintPosition() {
|
||||||
|
val from: ConstraintPosition get() = initialConstraint.position
|
||||||
|
|
||||||
override fun toString(): String = "Incorporate $initialConstraint from position $from"
|
override fun toString(): String = "Incorporate $initialConstraint from position $from"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user