Minor: simplified code

Used BoundKind.ordinal()
This commit is contained in:
Svetlana Isakova
2015-06-29 20:21:15 +03:00
parent ac578f7e5b
commit c6e698e18d
2 changed files with 6 additions and 11 deletions
@@ -40,8 +40,8 @@ public trait TypeBounds {
public enum class BoundKind {
LOWER_BOUND,
UPPER_BOUND,
EXACT_BOUND
EXACT_BOUND,
UPPER_BOUND
}
public class Bound(
@@ -67,15 +67,10 @@ private fun ConstraintSystemImpl.addConstraintFromBounds(old: Bound, new: Bound)
val newType = new.constrainingType
val position = CompoundConstraintPosition(old.position, new.position)
when (old.kind to new.kind) {
LOWER_BOUND to UPPER_BOUND, LOWER_BOUND to EXACT_BOUND, EXACT_BOUND to UPPER_BOUND ->
addConstraint(SUB_TYPE, 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)
when {
old.kind.ordinal() < new.kind.ordinal() -> 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)
}
}