Java: Simplify side effects check (IDEA-182669)

This commit is contained in:
Pavel Dolgov
2017-12-06 19:00:10 +03:00
parent 8be3715287
commit 971db5a4d6
4 changed files with 17 additions and 46 deletions

View File

@@ -1,8 +1,9 @@
// "Move 'return' closer to computation of the value of 'n'" "true"
class T {
int[] f(int k) {
int[] n = {-1};
if (k == 1)
return new int[]{1};
return new int[]{-1};
return n;
}
}

View File

@@ -3,8 +3,9 @@ import java.util.*;
class T {
List foo(boolean b) {
List n = new ArrayList();
if (b)
return null;
return new ArrayList();
return n;
}
}

View File

@@ -3,8 +3,9 @@ import java.util.*;
class T {
List foo(boolean b) {
List n = new ArrayList();
if (b)
return new ArrayList(1);
return new ArrayList();
return n;
}
}