KT-3576 Getters for float constants in objects always return 0.0 when constants are less than 1.0

#KT-3576 Fixed
This commit is contained in:
Mikhael Bogdanov
2013-05-06 10:41:48 +04:00
parent dd7c2cf78c
commit 22ddd05e09
3 changed files with 15 additions and 1 deletions
@@ -1593,7 +1593,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
if (type == Type.DOUBLE_TYPE && ((Number) value).doubleValue() == 0d) {
return true;
}
if (type == Type.FLOAT_TYPE && ((Number) value).byteValue() == 0f) {
if (type == Type.FLOAT_TYPE && ((Number) value).floatValue() == 0f) {
return true;
}
}
@@ -0,0 +1,9 @@
object TestObject {
val testFloat: Float = 0.9999
val otherFloat: Float = 1.01
}
fun box(): String {
return if (TestObject.testFloat.equals(0.9999.toFloat())
&& TestObject.otherFloat.equals(1.01.toFloat())) "OK" else "fail"
}
@@ -3336,6 +3336,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
doTest("compiler/testData/codegen/box/primitiveTypes/kt3078.kt");
}
@TestMetadata("kt3576.kt")
public void testKt3576() throws Exception {
doTest("compiler/testData/codegen/box/primitiveTypes/kt3576.kt");
}
@TestMetadata("kt446.kt")
public void testKt446() throws Exception {
doTest("compiler/testData/codegen/box/primitiveTypes/kt446.kt");