From 4f15bd4817f855a04325f09637821666654f3cbe Mon Sep 17 00:00:00 2001 From: Ivan Kylchik Date: Wed, 4 Aug 2021 14:16:18 +0300 Subject: [PATCH] Introduce a workaround in interpreter tests to make them pass There is a problem with ranges and iterators. To work properly they must be resolved firstly, before operator rangeTo. --- compiler/testData/ir/interpreter/loop.kt | 5 ++++- compiler/testData/ir/interpreter/primitives/charMethods.kt | 4 ++++ compiler/testData/ir/interpreter/primitives/intMethods.kt | 6 ++++++ compiler/testData/ir/interpreter/primitives/longMethods.kt | 4 ++++ compiler/testData/ir/interpreter/rangeTo.kt | 4 ++++ compiler/testData/ir/interpreter/spreadOperator.kt | 5 ++++- 6 files changed, 26 insertions(+), 2 deletions(-) diff --git a/compiler/testData/ir/interpreter/loop.kt b/compiler/testData/ir/interpreter/loop.kt index a08889c96d8..b87e8845860 100644 --- a/compiler/testData/ir/interpreter/loop.kt +++ b/compiler/testData/ir/interpreter/loop.kt @@ -1,4 +1,7 @@ -// IGNORE_BACKEND: JVM_IR +// this hack is used to ensure that iterator will be resolved first +@CompileTimeCalculation internal class IntProgressionIterator(first: Int, last: Int, val step: Int) : IntIterator() +@CompileTimeCalculation public class IntRange(start: Int, endInclusive: Int) : IntProgression(start, endInclusive, 1), ClosedRange + @CompileTimeCalculation fun loop(toInc: Int, start: Int, end: Int): Int { var result = toInc diff --git a/compiler/testData/ir/interpreter/primitives/charMethods.kt b/compiler/testData/ir/interpreter/primitives/charMethods.kt index c50da5894ca..c50e57043f0 100644 --- a/compiler/testData/ir/interpreter/primitives/charMethods.kt +++ b/compiler/testData/ir/interpreter/primitives/charMethods.kt @@ -1,3 +1,7 @@ +// this hack is used to ensure that iterator will be resolved first +@CompileTimeCalculation internal class CharProgressionIterator(first: Char, last: Char, val step: Int) : CharIterator() +@CompileTimeCalculation public class CharRange(start: Char, endInclusive: Char) : CharProgression(start, endInclusive, 1), ClosedRange + fun compareTo(first: Char, second: Char) = first.compareTo(second) fun plus(first: Char, second: Int) = first.plus(second) diff --git a/compiler/testData/ir/interpreter/primitives/intMethods.kt b/compiler/testData/ir/interpreter/primitives/intMethods.kt index 0d02aaea7e2..d29de799bf7 100644 --- a/compiler/testData/ir/interpreter/primitives/intMethods.kt +++ b/compiler/testData/ir/interpreter/primitives/intMethods.kt @@ -1,3 +1,9 @@ +// this hack is used to ensure that iterator will be resolved first +@CompileTimeCalculation internal class IntProgressionIterator(first: Int, last: Int, val step: Int) : IntIterator() +@CompileTimeCalculation public class IntRange(start: Int, endInclusive: Int) : IntProgression(start, endInclusive, 1), ClosedRange +@CompileTimeCalculation internal class LongProgressionIterator(first: Long, last: Long, val step: Long) : LongIterator() +@CompileTimeCalculation public class LongRange(start: Long, endInclusive: Long) : LongProgression(start, endInclusive, 1), ClosedRange + @CompileTimeCalculation fun compareTo(value: Int, other: Byte) = value.compareTo(other) @CompileTimeCalculation fun compareTo(value: Int, other: Short) = value.compareTo(other) @CompileTimeCalculation fun compareTo(value: Int, other: Int) = value.compareTo(other) diff --git a/compiler/testData/ir/interpreter/primitives/longMethods.kt b/compiler/testData/ir/interpreter/primitives/longMethods.kt index 1a34df8ceb9..02fc311402b 100644 --- a/compiler/testData/ir/interpreter/primitives/longMethods.kt +++ b/compiler/testData/ir/interpreter/primitives/longMethods.kt @@ -1,3 +1,7 @@ +// this hack is used to ensure that iterator will be resolved first +@CompileTimeCalculation internal class LongProgressionIterator(first: Long, last: Long, val step: Long) : LongIterator() +@CompileTimeCalculation public class LongRange(start: Long, endInclusive: Long) : LongProgression(start, endInclusive, 1), ClosedRange + @CompileTimeCalculation fun compareTo(value: Long, other: Byte) = value.compareTo(other) @CompileTimeCalculation fun compareTo(value: Long, other: Short) = value.compareTo(other) @CompileTimeCalculation fun compareTo(value: Long, other: Int) = value.compareTo(other) diff --git a/compiler/testData/ir/interpreter/rangeTo.kt b/compiler/testData/ir/interpreter/rangeTo.kt index a6ee31e6244..5ff90de921e 100644 --- a/compiler/testData/ir/interpreter/rangeTo.kt +++ b/compiler/testData/ir/interpreter/rangeTo.kt @@ -1,3 +1,7 @@ +// this hack is used to ensure that iterator will be resolved first +@CompileTimeCalculation internal class IntProgressionIterator(first: Int, last: Int, val step: Int) : IntIterator() +@CompileTimeCalculation public class IntRange(start: Int, endInclusive: Int) : IntProgression(start, endInclusive, 1), ClosedRange + const val range = (1..10).first @CompileTimeCalculation diff --git a/compiler/testData/ir/interpreter/spreadOperator.kt b/compiler/testData/ir/interpreter/spreadOperator.kt index 5a5408136b6..b84ff8e311f 100644 --- a/compiler/testData/ir/interpreter/spreadOperator.kt +++ b/compiler/testData/ir/interpreter/spreadOperator.kt @@ -1,4 +1,7 @@ -// IGNORE_BACKEND: JVM_IR +// this hack is used to ensure that iterator will be resolved first +@CompileTimeCalculation internal class IntProgressionIterator(first: Int, last: Int, val step: Int) : IntIterator() +@CompileTimeCalculation public class IntRange(start: Int, endInclusive: Int) : IntProgression(start, endInclusive, 1), ClosedRange + @CompileTimeCalculation fun varargSum(quantityToSum: Int, vararg num: Int): Int { var sum = 0