Files
kotlin/compiler/testData/codegen/bytecodeText/ranges/inNonMatchingRangeIntrinsified.kt
Dmitry Petrov 9d1901fc7c Intrinsify some mismatching range/element combinations for in/in!
It's safe to upcast integer types to Long,
floating-point types to Double.
So we don't have to create a range instance for cases such as

fun testLongInInt(x: Long, a: Int, b: Int) =
    x in a .. b

which is equivalent to

fun testLongInInt(x: Long, a: Int, b: Int) =
    x in a.toLong() .. b.toLong()
2017-07-10 10:51:26 +03:00

28 lines
406 B
Kotlin
Vendored

// WITH_RUNTIME
fun inInt(x: Long): Boolean {
return x in 1..2
}
fun inLong(x: Int): Boolean {
return x in 1L..2L
}
fun inFloat(x: Double): Boolean {
return x in 1.0f..2.0f
}
fun inDouble(x: Float): Boolean {
return x in 1.0..2.0
}
// 3 I2L
// 3 F2D
// 0 INVOKESPECIAL
// 0 NEW
// 0 rangeTo
// 0 longRangeContains
// 0 intRangeContains
// 0 doubleRangeContains
// 0 floatRangeContains