From baf7cbb3acc6386f323e2112fe0befdd0e941091 Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Fri, 12 Aug 2022 20:54:43 +0200 Subject: [PATCH] Add 'until' function for unsigned arguments to interpreter test helpers #KT-52933 Required to evaluate rangeUntil members of unsigned types. --- .../testData/ir/interpreter/helpers/Ranges.kt | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/compiler/testData/ir/interpreter/helpers/Ranges.kt b/compiler/testData/ir/interpreter/helpers/Ranges.kt index ff7c000995c..c32b5a1eac2 100644 --- a/compiler/testData/ir/interpreter/helpers/Ranges.kt +++ b/compiler/testData/ir/interpreter/helpers/Ranges.kt @@ -65,4 +65,24 @@ public infix fun Byte.until(to: Short): IntRange { } public infix fun Short.until(to: Short): IntRange { return this.toInt() .. (to.toInt() - 1).toInt() +} + +public infix fun UByte.until(to: UByte): UIntRange { + if (to <= UByte.MIN_VALUE) return UIntRange.EMPTY + return this.toUInt() .. (to - 1u).toUInt() +} + +public infix fun UInt.until(to: UInt): UIntRange { + if (to <= UInt.MIN_VALUE) return UIntRange.EMPTY + return this .. (to - 1u).toUInt() +} + +public infix fun ULong.until(to: ULong): ULongRange { + if (to <= ULong.MIN_VALUE) return ULongRange.EMPTY + return this .. (to - 1u).toULong() +} + +public infix fun UShort.until(to: UShort): UIntRange { + if (to <= UShort.MIN_VALUE) return UIntRange.EMPTY + return this.toUInt() .. (to - 1u).toUInt() } \ No newline at end of file