From 082ed62cd5f90c7a48bc7878863a967ccec3e275 Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Thu, 5 Oct 2017 19:11:10 +0300 Subject: [PATCH] Optimize ConstraintSystemBuilderImpl::generateNewBound Do not process the bound if it's just the same This situation can actually happen in case of adding bound containing type variable itself --- .../kotlin/resolve/calls/inference/constraintIncorporation.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt index 03dd23eca17..f0801e08408 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt @@ -82,6 +82,7 @@ private fun ConstraintSystemBuilderImpl.addConstraintFromBounds(old: Bound, new: } private fun ConstraintSystemBuilderImpl.generateNewBound(bound: Bound, substitution: Bound) { + if (bound === substitution) return // Let's have a bound 'T <=> My', and a substitution 'R <=> Type'. // Here <=> means lower_bound, upper_bound or exact_bound constraint. // Then a new bound 'T <=> My<_/in/out Type>' can be generated. @@ -127,4 +128,4 @@ private fun ConstraintSystemBuilderImpl.generateNewBound(bound: Bound, substitut if (approximationBounds.lower.containsConstrainingTypeWithoutProjection() && bound.kind != UPPER_BOUND) { addNewBound(approximationBounds.lower, LOWER_BOUND) } -} \ No newline at end of file +}