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()
This commit is contained in:
+27
@@ -0,0 +1,27 @@
|
||||
// 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
|
||||
Reference in New Issue
Block a user