IDEA-185445 Cannot return null from method returning BigDecimal

This commit is contained in:
alexey.afanasiev
2018-03-14 16:19:22 +03:00
parent e84e6936a5
commit 6b4fd56acd
2 changed files with 21 additions and 2 deletions
@@ -53,10 +53,10 @@ public class GrNumberConverter extends GrTypeConverter {
return isFloatOrDoubleType(targetType) ? OK : null;
if (TypesUtil.isClassType(targetType, JAVA_MATH_BIG_DECIMAL))
return TypesUtil.isNumericType(actualType) ? OK : ERROR;
return TypesUtil.isNumericType(actualType) || PsiType.NULL.equals(actualType) ? OK : ERROR;
if (TypesUtil.isClassType(targetType, JAVA_MATH_BIG_INTEGER))
return TypesUtil.isIntegralNumberType(actualType) ? OK : ERROR;
return TypesUtil.isIntegralNumberType(actualType) || PsiType.NULL.equals(actualType) ? OK : ERROR;
if (TypesUtil.isClassType(actualType, JAVA_MATH_BIG_INTEGER))
return TypesUtil.isClassType(targetType, JAVA_MATH_BIG_INTEGER) || TypesUtil.isClassType(targetType, JAVA_MATH_BIG_DECIMAL) ? OK : null;
@@ -134,6 +134,25 @@ class GrAssignAutoTest extends GrHighlightingTestBase {
'BigInteger -> int[]', 'BigInteger -> double[]', 'BigInteger -> short', 'int[] -> double[]', 'int[] -> Integer[]']
}
void testReturnAssignValue() {
doTest '''
@CompileStatic
%2$s method%3$s() {
return %1$s
}
''',
vectorProduct(values, types),
[],
['true -> int', 'true -> double', 'true -> short', 'true -> byte', 'false -> int', 'false -> double', 'false -> short',
'false -> byte', '(Void)null -> int', '(Void)null -> double', '(Void)null -> BigDecimal', '(Void)null -> BigInteger',
'(Void)null -> List', '(Void)null -> Thread', '(Void)null -> List<BigDecimal>', '(Void)null -> List<BigInteger>',
'(Void)null -> List<Integer>', '(Void)null -> List<String>', '(Void)null -> List<Object>', '(Void)null -> List<Thread>',
'(Void)null -> boolean[]', '(Void)null -> int[]', '(Void)null -> double[]', '(Void)null -> String[]',
'(Void)null -> Integer[]', '(Void)null -> List[]', '(Void)null -> Object[]', '(Void)null -> Thread[]',
'(Void)null -> short', '(Void)null -> byte', '(Void)null -> Set', '(Void)null -> Set<String>',
'(Void)null -> Set<Integer>', '(Void)null -> Set<Object>', '(Void)null -> Set<Thread>']
}
void testLocalAssignValue() {
doTest '''
@CompileStatic