Minor: simplified code
Used BoundKind.ordinal()
This commit is contained in:
@@ -40,8 +40,8 @@ public trait TypeBounds {
|
|||||||
|
|
||||||
public enum class BoundKind {
|
public enum class BoundKind {
|
||||||
LOWER_BOUND,
|
LOWER_BOUND,
|
||||||
UPPER_BOUND,
|
EXACT_BOUND,
|
||||||
EXACT_BOUND
|
UPPER_BOUND
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Bound(
|
public class Bound(
|
||||||
|
|||||||
+4
-9
@@ -67,15 +67,10 @@ private fun ConstraintSystemImpl.addConstraintFromBounds(old: Bound, new: Bound)
|
|||||||
val newType = new.constrainingType
|
val newType = new.constrainingType
|
||||||
val position = CompoundConstraintPosition(old.position, new.position)
|
val position = CompoundConstraintPosition(old.position, new.position)
|
||||||
|
|
||||||
when (old.kind to new.kind) {
|
when {
|
||||||
LOWER_BOUND to UPPER_BOUND, LOWER_BOUND to EXACT_BOUND, EXACT_BOUND to UPPER_BOUND ->
|
old.kind.ordinal() < new.kind.ordinal() -> addConstraint(SUB_TYPE, oldType, newType, position)
|
||||||
addConstraint(SUB_TYPE, oldType, newType, position)
|
old.kind.ordinal() > new.kind.ordinal() -> addConstraint(SUB_TYPE, newType, oldType, position)
|
||||||
|
old.kind == new.kind && old.kind == EXACT_BOUND -> addConstraint(EQUAL, oldType, newType, position)
|
||||||
UPPER_BOUND to LOWER_BOUND, UPPER_BOUND to EXACT_BOUND, EXACT_BOUND to LOWER_BOUND ->
|
|
||||||
addConstraint(SUB_TYPE, newType, oldType, position)
|
|
||||||
|
|
||||||
EXACT_BOUND to EXACT_BOUND ->
|
|
||||||
addConstraint(EQUAL, oldType, newType, position)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user