diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/constants/CompileTimeConstantResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/constants/CompileTimeConstantResolver.java index 0005fec798c..e1bb1c33992 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/constants/CompileTimeConstantResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/constants/CompileTimeConstantResolver.java @@ -132,7 +132,7 @@ public class CompileTimeConstantResolver { } else if (JetTypeChecker.INSTANCE.isSubtypeOf(builtIns.getFloatType(), expectedType)) { try { - return new DoubleValue(Float.parseFloat(text)); + return new FloatValue(Float.parseFloat(text)); } catch (NumberFormatException e) { return OUT_OF_RANGE; diff --git a/compiler/testData/diagnostics/tests/Constants.kt b/compiler/testData/diagnostics/tests/Constants.kt index b0993ea0d0f..2a2960a644f 100644 --- a/compiler/testData/diagnostics/tests/Constants.kt +++ b/compiler/testData/diagnostics/tests/Constants.kt @@ -1,8 +1,25 @@ fun test() { - 1 : Byte - 1 : Int - 1 : Double - 1 as Byte - 1 as Int - 1 as Double -} + 1: Byte + 1: Short + 1: Int + 1: Long + + 0x001: Long + 0b001: Int + + 0.1: Double + 0.1: Float + + 1e5: Double + 1e-5: Float + + 1: Double + 1: Float + + 1 as Byte + 1 as Int + 0xff as Long + + 1.1 as Int + 1.1: Int +} \ No newline at end of file