report only 'The value is out of range'

not 'An integer literal does not conform to the expected type Int/Long'
This commit is contained in:
Svetlana Isakova
2013-07-23 15:28:25 +04:00
parent f2746b835e
commit 0849798af0
3 changed files with 24 additions and 4 deletions
@@ -78,11 +78,10 @@ public class CompileTimeConstantResolver {
@NotNull
public CompileTimeConstant<?> getIntegerValue(@Nullable Long value, @NotNull JetType expectedType) {
if (value == null) {
return OUT_OF_RANGE;
}
if (noExpectedType(expectedType)) {
if (value == null) {
return OUT_OF_RANGE;
}
if (Integer.MIN_VALUE <= value && value <= Integer.MAX_VALUE) {
return new IntValue(value.intValue());
}
@@ -0,0 +1,16 @@
package a
fun foo(i: Int) = i
fun bar(l: Long) = l
fun main(args: Array<String>) {
val <!UNUSED_VARIABLE!>i<!> = <!ERROR_COMPILE_TIME_VALUE!>111111111111111777777777777777<!>
//todo add diagnostic text messages
//report only 'The value is out of range'
//not 'An integer literal does not conform to the expected type Int/Long'
val <!UNUSED_VARIABLE!>l<!>: Long = <!ERROR_COMPILE_TIME_VALUE!>1111111111111117777777777777777<!>
foo(<!ERROR_COMPILE_TIME_VALUE!>11111111111111177777777777777<!>)
bar(<!ERROR_COMPILE_TIME_VALUE!>11111111111111177777777777777<!>)
}
@@ -3789,6 +3789,11 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
doTest("compiler/testData/diagnostics/tests/numbers/doublesInSimpleConstraints.kt");
}
@TestMetadata("intValuesOutOfRange.kt")
public void testIntValuesOutOfRange() throws Exception {
doTest("compiler/testData/diagnostics/tests/numbers/intValuesOutOfRange.kt");
}
@TestMetadata("numbersInSimpleConstraints.kt")
public void testNumbersInSimpleConstraints() throws Exception {
doTest("compiler/testData/diagnostics/tests/numbers/numbersInSimpleConstraints.kt");