Files
kotlin-fork/compiler/testData/codegen/box/ieee754/greaterFloat.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

25 lines
753 B
Kotlin
Vendored

// !LANGUAGE: -ProperIeee754Comparisons
// DONT_TARGET_EXACT_BACKEND: JS_IR
fun greater1(a: Float, b: Float) = a > b
fun greater2(a: Float?, b: Float?) = a!! > b!!
fun greater3(a: Float?, b: Float?) = a != null && b != null && a > b
fun greater4(a: Float?, b: Float?) = if (a is Float && b is Float) a > b else null!!
fun greater5(a: Any?, b: Any?) = if (a is Float && b is Float) a > b else null!!
fun box(): String {
if (0.0F > -0.0F) return "fail 0"
if (greater1(0.0F, -0.0F)) return "fail 1"
if (greater2(0.0F, -0.0F)) return "fail 2"
if (greater3(0.0F, -0.0F)) return "fail 3"
if (greater4(0.0F, -0.0F)) return "fail 4"
// Smart casts behavior in 1.2
if (!greater5(0.0F, -0.0F)) return "fail 5"
return "OK"
}