RangeContainsLowering: Fix bug in additional condition order for

`until` ranges.
This commit is contained in:
Mark Punzalan
2020-08-07 23:19:44 -07:00
committed by Alexander Udalov
parent 60a2f7d03f
commit ceba9f231d
3 changed files with 37 additions and 1 deletions
@@ -336,7 +336,9 @@ private class Transformer(
).let {
if (additionalNotEmptyCondition != null) {
// Add additional condition, currently used in `until` ranges (see UntilHandler.kt).
context.andand(additionalNotEmptyCondition, it)
// NOTE: The additional condition must be on the RIGHT side of the &&, to guarantee that the expressions for the bounds
// and argument are evaluated as designed. (See big comment above on expressions with side effects and temp variables.)
context.andand(it, additionalNotEmptyCondition)
} else {
it
}