c9bdfd2f07
Take into account: 1) resolved call to compareTo (instead of always calling Comparable's method) 2) types of both caller and callee, when primitive, to avoid wrong casting (instead of always using caller's type) #KT-3078 Fixed
17 lines
441 B
Kotlin
17 lines
441 B
Kotlin
fun checkLess(x: Array<Int>, y: Array<Int>) = when {
|
|
x >= y -> "Fail $x >= $y"
|
|
!(x < y) -> "Fail !($x < $y)"
|
|
!(x <= y) -> "Fail !($x <= $y)"
|
|
x > y -> "Fail $x > $y"
|
|
x.compareTo(y) >= 0 -> "Fail $x.compareTo($y) >= 0"
|
|
else -> "OK"
|
|
}
|
|
|
|
fun Array<Int>.compareTo(other: Array<Int>) = size - other.size
|
|
|
|
fun box(): String {
|
|
val a = Array<Int>(0, {0})
|
|
val b = Array<Int>(1, {0})
|
|
return checkLess(a, b)
|
|
}
|