Files
kotlin-fork/compiler/testData/ir/irText/expressions/floatingPointComparisons/floatingPointCompareTo.kt
T
Mads Ager e8a640851a FIR: Change the Fir2Ir handling of smart casts.
Generate the expression with the original type and then insert
an implicit conversion. That matches the behavior of psi2ir
better and therefore avoids breaking backend assumptions.

In particular, IrGetValue expects the type of the underlying
symbol and the type of the IrGetValue to be the same.
2020-01-31 09:31:52 +01:00

16 lines
726 B
Kotlin
Vendored

// FIR_IDENTICAL
fun test1d(x: Double, y: Double) = x.compareTo(y)
fun test2d(x: Double, y: Any) = y is Double && x.compareTo(y) == 0
fun test3d(x: Any, y: Any) = x is Double && y is Double && x.compareTo(y) == 0
fun test1f(x: Float, y: Float) = x.compareTo(y)
fun test2f(x: Float, y: Any) = y is Float && x.compareTo(y) == 0
fun test3f(x: Any, y: Any) = x is Float && y is Float && x.compareTo(y) == 0
fun testFD(x: Any, y: Any) = x is Float && y is Double && x.compareTo(y) == 0
fun testDF(x: Any, y: Any) = x is Double && y is Float && x.compareTo(y) == 0
fun Float.test1fr(x: Float) = compareTo(x)
fun Float.test2fr(x: Any) = x is Float && compareTo(x) == 0
fun Float.test3fr(x: Any) = x is Double && compareTo(x) == 0