KT-1895 Make it possible to pass 1.0 as Float without explicit casting
#KT-1895 fixed
This commit is contained in:
+1
-1
@@ -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;
|
||||
|
||||
@@ -1,8 +1,25 @@
|
||||
fun test() {
|
||||
1 : Byte
|
||||
1 : Int
|
||||
<!TYPE_MISMATCH!>1<!> : Double
|
||||
1 <!USELESS_CAST!>as<!> Byte
|
||||
1 <!USELESS_CAST!>as<!> Int
|
||||
<!ERROR_COMPILE_TIME_VALUE!>1<!> <!CAST_NEVER_SUCCEEDS!>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
|
||||
|
||||
<!TYPE_MISMATCH!>1<!>: Double
|
||||
<!TYPE_MISMATCH!>1<!>: Float
|
||||
|
||||
1 <!USELESS_CAST!>as<!> Byte
|
||||
1 <!USELESS_CAST!>as<!> Int
|
||||
0xff <!USELESS_CAST!>as<!> Long
|
||||
|
||||
<!ERROR_COMPILE_TIME_VALUE!>1.1<!> <!CAST_NEVER_SUCCEEDS!>as<!> Int
|
||||
<!TYPE_MISMATCH!>1.1<!>: Int
|
||||
}
|
||||
Reference in New Issue
Block a user