Files
kotlin/compiler/testData/codegen/bytecodeText/ieee754/smartCastsForFloat.kt
Mads Ager 690b8e0ac9 JVM_IR: Optimize null checks.
Introduce lowering to remove null checks for primitive type
expressions and replace them with true/false. Side-effects
are preserved.

Generate ifnull/ifnonnull instructions for null checks instead
of materializing a null literal for an equality check.
2019-01-19 09:43:43 +01:00

23 lines
679 B
Kotlin
Vendored

// !LANGUAGE: +ProperIeee754Comparisons
fun equals5(a: Any?, b: Any?) = if (a is Float && b is Float?) a == b else null!!
fun equals6(a: Any?, b: Any?) = if (a is Float? && b is Float) a == b else null!!
fun equals8(a: Any?, b: Any?) = if (a is Float? && b is Float?) a == b else null!!
fun box(): String {
if (!equals5(-0.0F, 0.0F)) return "fail 5"
if (!equals6(-0.0F, 0.0F)) return "fail 6"
if (!equals8(-0.0F, 0.0F)) return "fail 8"
if (!equals8(null, null)) return "fail 9"
if (equals8(null, 0.0F)) return "fail 10"
if (equals8(0.0F, null)) return "fail 11"
return "OK"
}
// 3 areEqual \(Ljava/lang/Float;Ljava/lang/Float;\)Z
// 3 areEqual