diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/model/MutableConstraintStorage.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/model/MutableConstraintStorage.kt index 49026b11e99..7b41a55bdff 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/model/MutableConstraintStorage.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/model/MutableConstraintStorage.kt @@ -103,33 +103,10 @@ class MutableVariableWithConstraints( } private fun simplifyConstraints(): List { - val distinctConstraints = removeDuplicatesFromDeclaredUpperBoundConstraints(mutableConstraints) - - val equalityConstraints = distinctConstraints + val equalityConstraints = mutableConstraints .filter { it.kind == ConstraintKind.EQUALITY } .groupBy { it.typeHashCode } - return distinctConstraints.filter { isUsefulConstraint(it, equalityConstraints) } - } - - private fun removeDuplicatesFromDeclaredUpperBoundConstraints(constraints: List): MutableList { - val currentConstraints = constraints.toMutableList() - val iterator = currentConstraints.iterator() - while (iterator.hasNext()) { - val potentialDuplicate = iterator.next() - - if (potentialDuplicate.position.from !is DeclaredUpperBoundConstraintPosition) continue - val hasDuplicate = currentConstraints.any { other -> - potentialDuplicate !== other && - potentialDuplicate.typeHashCode == other.typeHashCode && - potentialDuplicate.type == other.type && - potentialDuplicate.kind == other.kind - } - - if (hasDuplicate) - iterator.remove() - } - - return currentConstraints + return mutableConstraints.filter { isUsefulConstraint(it, equalityConstraints) } } private fun isUsefulConstraint(constraint: Constraint, equalityConstraints: Map>): Boolean { diff --git a/compiler/testData/diagnostics/tests/smartCasts/lambdaArgumentWithBoundWithoutType.kt b/compiler/testData/diagnostics/tests/smartCasts/lambdaArgumentWithBoundWithoutType.kt index c785e34077e..2a1a6f3b5b2 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/lambdaArgumentWithBoundWithoutType.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/lambdaArgumentWithBoundWithoutType.kt @@ -22,5 +22,5 @@ val foofoo: Foo = run { val bar: Bar = run { val x = foo() if (x == null) throw Exception() - x + x }