e1b41eee15
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
21 lines
440 B
Kotlin
Vendored
21 lines
440 B
Kotlin
Vendored
inline fun eq(a: Any, b: Any) = a == b
|
|
inline fun ne(a: Any, b: Any) = a != b
|
|
|
|
val ONE = 1
|
|
val ONEL = 1L
|
|
|
|
fun box(): String {
|
|
return when {
|
|
eq(ONE, 2) -> "Fail 1"
|
|
!eq(ONE, 1) -> "Fail 2"
|
|
!ne(ONE, 2) -> "Fail 3"
|
|
ne(ONE, 1) -> "Fail 4"
|
|
|
|
eq(ONEL, 42L) -> "Fail 1L"
|
|
!eq(ONEL, 1L) -> "Fail 2L"
|
|
!ne(ONEL, 42L) -> "Fail 3L"
|
|
ne(ONEL, 1L) -> "Fail 4L"
|
|
|
|
else -> "OK"
|
|
}
|
|
} |