MismatchedArrayReadWrite: fix when array is passed as the second argument of Arrays.fill.

This commit is contained in:
Tagir Valeev
2018-10-08 16:00:08 +07:00
parent 8b23bed2b1
commit bdcfaf778e
2 changed files with 9 additions and 2 deletions
@@ -298,8 +298,9 @@ public class MismatchedArrayReadWriteInspection extends BaseInspection {
}
}
else if (CommonClassNames.JAVA_UTIL_ARRAYS.equals(qualifiedName)) {
if ("fill".equals(methodName) || "parallelPrefix".equals(methodName) || "parallelSetAll".equals(methodName) ||
"parallelSort".equals(methodName) || "setAll".equals(methodName) || "sort".equals(methodName)) {
if (("fill".equals(methodName) || "parallelPrefix".equals(methodName) || "parallelSetAll".equals(methodName) ||
"parallelSort".equals(methodName) || "setAll".equals(methodName) || "sort".equals(methodName)) &&
PsiTreeUtil.isAncestor(expressionList.getExpressions()[0], expression, false)) {
myWritten = true;
}
else {
@@ -84,6 +84,12 @@ public class MismatchedArrayReadWrite {
allResults[row] = new int[9];
}
}
void fillSecondArg(int[][] data) {
int[] arr = new int[3];
arr[0] = 0;
Arrays.fill(data, arr);
}
}
class Test{
public void bar(){