diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/typeEnhancers/GrNumberConverter.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/typeEnhancers/GrNumberConverter.java index 275a83bd3ea9..4881e05acecb 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/typeEnhancers/GrNumberConverter.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/typeEnhancers/GrNumberConverter.java @@ -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; diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GrAssignAutoTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GrAssignAutoTest.groovy index 32591a258dce..25d0666160c1 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GrAssignAutoTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GrAssignAutoTest.groovy @@ -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', '(Void)null -> List', + '(Void)null -> List', '(Void)null -> List', '(Void)null -> List', '(Void)null -> List', + '(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', + '(Void)null -> Set', '(Void)null -> Set', '(Void)null -> Set'] + } + void testLocalAssignValue() { doTest ''' @CompileStatic