ensure cast to class type is suggested when argument type is null (IDEA-159884)

This commit is contained in:
Anna Kozlova
2016-08-16 17:39:07 +03:00
parent 74c9a08a25
commit e743d2ad59
3 changed files with 21 additions and 0 deletions
@@ -61,6 +61,9 @@ public class CastMethodArgumentFix extends MethodArgumentFix implements HighPrio
if (parameterType == null) return false;
}
if (exprType instanceof PsiPrimitiveType && parameterType instanceof PsiClassType) {
if (PsiType.NULL.equals(exprType)) {
return true;
}
parameterType = PsiPrimitiveType.getUnboxedType(parameterType);
if (parameterType == null) return false;
}
@@ -0,0 +1,9 @@
// "Cast parameter to 'java.lang.String'" "true"
class a {
void f(Long... l) {}
void f(String s) {}
void g() {
f((String) null);
}
}
@@ -0,0 +1,9 @@
// "Cast parameter to 'java.lang.String'" "true"
class a {
void f(Long... l) {}
void f(String s) {}
void g() {
f(<caret>null);
}
}