Stricter type checks in 'convert to range' intention (#1073)

#KT-17079 #KT-17762 Fixed
This commit is contained in:
nd
2017-05-09 09:31:32 +02:00
committed by Dmitry Jemerov
parent e76f1acc0b
commit e20e097a63
11 changed files with 156 additions and 11 deletions
@@ -0,0 +1,5 @@
// IS_APPLICABLE: false
// DISABLE-ERRORS
fun foo(bar: Char) {
bar > 1 && 2 > bar<caret>
}
@@ -0,0 +1,10 @@
// WITH_RUNTIME
class A(val _value: Int): Comparable<A> {
override operator fun compareTo(other: A) = _value.compareTo(other._value)
}
val low = A(0)
val high = A(100)
fun test(a: A): Boolean {
return low <= a && a <= high<caret>
}
@@ -0,0 +1,10 @@
// WITH_RUNTIME
class A(val _value: Int): Comparable<A> {
override operator fun compareTo(other: A) = _value.compareTo(other._value)
}
val low = A(0)
val high = A(100)
fun test(a: A): Boolean {
return a in low..high
}
@@ -0,0 +1,9 @@
// IS_APPLICABLE: false
// WITH_RUNTIME
class A(val _value: Int) {
operator fun compareTo(other: Int) = _value.compareTo(other)
}
fun test(a: A): Boolean {
return a >= 0 && a <= 100<caret>
}
@@ -0,0 +1,11 @@
// IS_APPLICABLE: false
// WITH_RUNTIME
class A(val _value: Int) {
operator fun compareTo(other: A) = _value.compareTo(other._value)
}
val low = A(0)
val high = A(100)
fun test(a: A): Boolean {
return low <= a && a <= high<caret>
}
@@ -0,0 +1,4 @@
// WITH_RUNTIME
fun foo(bar: Double) {
0 <= bar && bar <= 10.0<caret>
}
@@ -0,0 +1,4 @@
// WITH_RUNTIME
fun foo(bar: Double) {
bar in 0.0..10.0
}
@@ -0,0 +1,4 @@
// WITH_RUNTIME
fun foo(bar: Double) {
0 <= bar && bar <= 10<caret>
}
@@ -0,0 +1,4 @@
// WITH_RUNTIME
fun foo(bar: Double) {
bar in 0.0..10.0
}