IDEA-179716 Cannot return Integer from method returning short. Fix docs.

This commit is contained in:
alexey.afanasiev
2017-10-10 17:45:46 +03:00
parent bc1f515ce8
commit 4ffd02dd8b
3 changed files with 8 additions and 6 deletions
@@ -795,7 +795,7 @@ public class GroovyTypeCheckVisitor extends BaseInspectionVisitor {
);
}
//copypaste from org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.checkPossibleLooseOfPrecision()
//see org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.checkPossibleLooseOfPrecision()
static boolean isPossibleLooseOfPrecision(@NotNull PsiType targetType, @NotNull PsiType actualType, @NotNull GrExpression expression) {
int targetRank = getTypeRank(targetType);
int actualRank = getTypeRank(actualType);
@@ -36,9 +36,10 @@ public class GrContainerTypeConverter extends GrTypeConverter {
return null;
}
private static ConversionResult isCSConvertible(PsiType targetType,
PsiType actualType,
GroovyPsiElement context) {
@Nullable
private static ConversionResult isCSConvertible(@NotNull PsiType targetType,
@NotNull PsiType actualType,
@NotNull GroovyPsiElement context) {
if (targetType instanceof PsiArrayType && actualType instanceof PsiArrayType) {
return TypesUtil.isAssignableByParameter(((PsiArrayType)targetType).getComponentType(), ((PsiArrayType)actualType).getComponentType(),
context) ? ConversionResult.OK : ConversionResult.ERROR;
@@ -28,14 +28,15 @@ public class GrNumberConverter extends GrTypeConverter {
@NotNull PsiType actualType,
@NotNull GroovyPsiElement context,
@NotNull ApplicableTo currentPosition) {
if (PsiUtil.isCompileStatic(context)) return isCSConvertible(targetType, actualType, context, currentPosition);
if (PsiUtil.isCompileStatic(context)) return isCSConvertible(targetType, actualType);
if (TypesUtil.isNumericType(targetType) && TypesUtil.isNumericType(actualType)) {
return OK;
}
return null;
}
private static ConversionResult isCSConvertible(PsiType targetType, PsiType actualType, GroovyPsiElement context, @NotNull ApplicableTo currentPosition) {
@Nullable
private static ConversionResult isCSConvertible(@NotNull PsiType targetType, @NotNull PsiType actualType) {
if (TypesUtil.isClassType(actualType, JAVA_MATH_BIG_DECIMAL))
return isFloatOrDoubleType(targetType) ? OK : null;