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
This commit is contained in:
Denis Zharkov
2017-10-05 19:11:10 +03:00
parent 3a9650d0fc
commit 082ed62cd5
@@ -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<R>', 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)
}
}
}