From c6e698e18d851399b5feec4d6c598d26267d531d Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Mon, 29 Jun 2015 20:21:15 +0300 Subject: [PATCH] Minor: simplified code Used BoundKind.ordinal() --- .../kotlin/resolve/calls/inference/TypeBounds.kt | 4 ++-- .../calls/inference/constraintIncorporation.kt | 13 ++++--------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBounds.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBounds.kt index ff52b07e878..bee0e0ab739 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBounds.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBounds.kt @@ -40,8 +40,8 @@ public trait TypeBounds { public enum class BoundKind { LOWER_BOUND, - UPPER_BOUND, - EXACT_BOUND + EXACT_BOUND, + UPPER_BOUND } public class Bound( diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt index b1167b1a5bf..2a77ccbbb61 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt @@ -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) } }