mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 15:53:19 +00:00
Support Comparable#compareTo for boxed primitive in redundant boxing/unboxing analysis, along with CHECKCAST to java.lang.Comparable. Note that we can do that for Float and Double, too, because Float#compareTo(Float) and Double#compareTo(Double) are delegated to Float#compare(float, float) and Double#compare(double, double), respectively. Fuse specialized comparison for integers with conditional jumps if possible (both for Comparable#compareTo and Intrinsics#areEqual). #KT-11959 Fixed
8 lines
169 B
Kotlin
Vendored
8 lines
169 B
Kotlin
Vendored
fun box(): String {
|
|
val a: Any = 1
|
|
val b: Any = 42
|
|
val test = (a as Comparable<Any>).compareTo(b)
|
|
if (test != -1) return "Fail: $test"
|
|
|
|
return "OK"
|
|
} |