[FIR] Add empty range checker
This commit is contained in:
+29
@@ -0,0 +1,29 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun foo() {
|
||||
for (i in 1..2) { }
|
||||
|
||||
val a = 3..4
|
||||
|
||||
val v = 1
|
||||
if (v in 5..6) { }
|
||||
}
|
||||
|
||||
|
||||
fun backward() {
|
||||
for (i in 2 downTo 1) { }
|
||||
|
||||
val a = 4 downTo 3
|
||||
|
||||
val v = 1
|
||||
if (v in -5 downTo -6) { }
|
||||
}
|
||||
|
||||
fun until() {
|
||||
for (i in 1 until 2) { }
|
||||
|
||||
val a = 3 until 4
|
||||
|
||||
val v = 1
|
||||
if (v in -5 until -4) { }
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
FILE: NoWarning.kt
|
||||
public final fun foo(): R|kotlin/Unit| {
|
||||
lval <iterator>: R|kotlin/collections/IntIterator| = Int(1).R|kotlin/Int.rangeTo|(Int(2)).R|kotlin/ranges/IntProgression.iterator|()
|
||||
while(R|<local>/<iterator>|.R|kotlin/collections/Iterator.hasNext|()) {
|
||||
lval i: R|kotlin/Int| = R|<local>/<iterator>|.R|kotlin/collections/IntIterator.next|()
|
||||
}
|
||||
|
||||
lval a: R|kotlin/ranges/IntRange| = Int(3).R|kotlin/Int.rangeTo|(Int(4))
|
||||
lval v: R|kotlin/Int| = Int(1)
|
||||
when () {
|
||||
Int(5).R|kotlin/Int.rangeTo|(Int(6)).R|kotlin/ranges/IntRange.contains|(R|<local>/v|) -> {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public final fun backward(): R|kotlin/Unit| {
|
||||
lval <iterator>: R|kotlin/collections/IntIterator| = Int(2).R|kotlin/ranges/downTo|(Int(1)).R|kotlin/ranges/IntProgression.iterator|()
|
||||
while(R|<local>/<iterator>|.R|kotlin/collections/Iterator.hasNext|()) {
|
||||
lval i: R|kotlin/Int| = R|<local>/<iterator>|.R|kotlin/collections/IntIterator.next|()
|
||||
}
|
||||
|
||||
lval a: R|kotlin/ranges/IntProgression| = Int(4).R|kotlin/ranges/downTo|(Int(3))
|
||||
lval v: R|kotlin/Int| = Int(1)
|
||||
when () {
|
||||
Int(5).R|kotlin/Int.unaryMinus|().R|kotlin/ranges/downTo|(Int(6).R|kotlin/Int.unaryMinus|()).R|kotlin/collections/contains|<R|kotlin/Int|>(R|<local>/v|) -> {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public final fun until(): R|kotlin/Unit| {
|
||||
lval <iterator>: R|kotlin/collections/IntIterator| = Int(1).R|kotlin/ranges/until|(Int(2)).R|kotlin/ranges/IntProgression.iterator|()
|
||||
while(R|<local>/<iterator>|.R|kotlin/collections/Iterator.hasNext|()) {
|
||||
lval i: R|kotlin/Int| = R|<local>/<iterator>|.R|kotlin/collections/IntIterator.next|()
|
||||
}
|
||||
|
||||
lval a: R|kotlin/ranges/IntRange| = Int(3).R|kotlin/ranges/until|(Int(4))
|
||||
lval v: R|kotlin/Int| = Int(1)
|
||||
when () {
|
||||
Int(5).R|kotlin/Int.unaryMinus|().R|kotlin/ranges/until|(Int(4).R|kotlin/Int.unaryMinus|()).R|kotlin/ranges/IntRange.contains|(R|<local>/v|) -> {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun foo() {
|
||||
for (i in <!EMPTY_RANGE!>2..1<!>) { }
|
||||
|
||||
val a = <!EMPTY_RANGE!>10..0<!>
|
||||
|
||||
val v = 1
|
||||
if (v in <!EMPTY_RANGE!>10..1<!>) { }
|
||||
}
|
||||
|
||||
fun backward() {
|
||||
for (i in <!EMPTY_RANGE!>1 downTo 2<!>) { }
|
||||
|
||||
val a = <!EMPTY_RANGE!>-3 downTo 4<!>
|
||||
|
||||
val v = 1
|
||||
if (v in <!EMPTY_RANGE!>0 downTo 6<!>) { }
|
||||
}
|
||||
|
||||
fun until() {
|
||||
for (i in <!EMPTY_RANGE!>1 until 1<!>) { }
|
||||
|
||||
val a = <!EMPTY_RANGE!>4 until 3<!>
|
||||
|
||||
val v = 1
|
||||
if (v in <!EMPTY_RANGE!>-5 until -5<!>) { }
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
FILE: Warning.kt
|
||||
public final fun foo(): R|kotlin/Unit| {
|
||||
lval <iterator>: R|kotlin/collections/IntIterator| = Int(2).R|kotlin/Int.rangeTo|(Int(1)).R|kotlin/ranges/IntProgression.iterator|()
|
||||
while(R|<local>/<iterator>|.R|kotlin/collections/Iterator.hasNext|()) {
|
||||
lval i: R|kotlin/Int| = R|<local>/<iterator>|.R|kotlin/collections/IntIterator.next|()
|
||||
}
|
||||
|
||||
lval a: R|kotlin/ranges/IntRange| = Int(10).R|kotlin/Int.rangeTo|(Int(0))
|
||||
lval v: R|kotlin/Int| = Int(1)
|
||||
when () {
|
||||
Int(10).R|kotlin/Int.rangeTo|(Int(1)).R|kotlin/ranges/IntRange.contains|(R|<local>/v|) -> {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public final fun backward(): R|kotlin/Unit| {
|
||||
lval <iterator>: R|kotlin/collections/IntIterator| = Int(1).R|kotlin/ranges/downTo|(Int(2)).R|kotlin/ranges/IntProgression.iterator|()
|
||||
while(R|<local>/<iterator>|.R|kotlin/collections/Iterator.hasNext|()) {
|
||||
lval i: R|kotlin/Int| = R|<local>/<iterator>|.R|kotlin/collections/IntIterator.next|()
|
||||
}
|
||||
|
||||
lval a: R|kotlin/ranges/IntProgression| = Int(3).R|kotlin/Int.unaryMinus|().R|kotlin/ranges/downTo|(Int(4))
|
||||
lval v: R|kotlin/Int| = Int(1)
|
||||
when () {
|
||||
Int(0).R|kotlin/ranges/downTo|(Int(6)).R|kotlin/collections/contains|<R|kotlin/Int|>(R|<local>/v|) -> {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public final fun until(): R|kotlin/Unit| {
|
||||
lval <iterator>: R|kotlin/collections/IntIterator| = Int(1).R|kotlin/ranges/until|(Int(1)).R|kotlin/ranges/IntProgression.iterator|()
|
||||
while(R|<local>/<iterator>|.R|kotlin/collections/Iterator.hasNext|()) {
|
||||
lval i: R|kotlin/Int| = R|<local>/<iterator>|.R|kotlin/collections/IntIterator.next|()
|
||||
}
|
||||
|
||||
lval a: R|kotlin/ranges/IntRange| = Int(4).R|kotlin/ranges/until|(Int(3))
|
||||
lval v: R|kotlin/Int| = Int(1)
|
||||
when () {
|
||||
Int(5).R|kotlin/Int.unaryMinus|().R|kotlin/ranges/until|(Int(5).R|kotlin/Int.unaryMinus|()).R|kotlin/ranges/IntRange.contains|(R|<local>/v|) -> {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user