Java inspection: Fixed catch finally in "Move return to computation" (IDEA-121153)

This commit is contained in:
Pavel Dolgov
2016-09-06 19:05:05 +03:00
parent 21bc6ce944
commit 04430d7f73
24 changed files with 373 additions and 25 deletions
@@ -4,6 +4,6 @@ class T {
int n = 0;
if (b) System.out.println("yes");
else return 2;
return 0;
return n;
}
}
@@ -4,6 +4,6 @@ class T {
int n = 0;
if (b) return 1;
else System.out.println("no");
return 0;
return n;
}
}
@@ -7,6 +7,6 @@ class T {
return i;
}
}
return -1;
return n;
}
}
@@ -3,6 +3,6 @@ class T {
int f(boolean b) {
int n = 0;
if (b) return 1;
return 0;
return n;
}
}
@@ -3,6 +3,6 @@ class T {
int f(boolean b, int d) {
int n = d;
if (b) return 1;
return d;
return n;
}
}
@@ -8,7 +8,7 @@ class T {
return s;
}
}
return "";
return r;
}
boolean hasNext() {
@@ -0,0 +1,16 @@
// "Move 'return' to computation of the value of 'n'" "true"
class T {
int f(boolean b) {
int n = -1;
try {
n = 1;
if (b) {
throw new RuntimeException();
}
return n;
}
catch (RuntimeException e) {
return 2;
}
}
}
@@ -0,0 +1,24 @@
// "Move 'return' to computation of the value of 'n'" "true"
import java.io.*;
class T {
int f(boolean b, boolean c) {
int n = -1;
try {
n = 1;
if (b) throw new IOException();
n = 2;
if (c) throw new RuntimeException();
return n;
}
catch (IOException e) {
throw new RuntimeException(e);
}
catch (RuntimeException e) {
return 3;
}
finally {
System.out.println();
}
}
}
@@ -0,0 +1,24 @@
// "Move 'return' to computation of the value of 'n'" "true"
import java.io.*;
class T {
int f(boolean b, boolean c) {
int n = -1;
try {
n = 1;
if (b) throw new IOException();
n = 2;
if (c) throw new RuntimeException();
return n;
}
catch (IOException e) {
throw new RuntimeException(e);
}
catch (RuntimeException e) {
return 3;
}
finally {
System.out.println();
}
}
}
@@ -0,0 +1,24 @@
// "Move 'return' to computation of the value of 'n'" "true"
import java.io.*;
class T {
int f(boolean b, boolean c) {
int n = -1;
try {
n = 1;
if (b) throw new IOException();
n = 2;
if (c) throw new RuntimeException();
return n;
}
catch (IOException e) {
throw new RuntimeException(e);
}
catch (RuntimeException e) {
return 3;
}
finally {
return 4;
}
}
}
@@ -0,0 +1,24 @@
// "Move 'return' to computation of the value of 'n'" "true"
import java.io.*;
class T {
int f(boolean b, boolean c, boolean d) {
int n = -1;
try {
n = 1;
if (b) throw new IOException();
n = 2;
if (c) throw new RuntimeException();
return n;
}
catch (IOException e) {
throw new RuntimeException(e);
}
catch (RuntimeException e) {
return 3;
}
finally {
if(d) return 4;
}
}
}
@@ -0,0 +1,16 @@
// "Move 'return' to computation of the value of 'n'" "true"
class T {
int f(boolean b) {
int n = -1;
try {
n = 1;
if (b) {
throw new RuntimeException();
}
return n;
}
catch (RuntimeException e) {
throw new RuntimeException(e);
}
}
}
@@ -0,0 +1,16 @@
// "Move 'return' to computation of the value of 'n'" "true"
class T {
int f(boolean b) {
int n = -1;
try {
n = 1;
if (b) {
throw new RuntimeException();
}
return n;
}
catch (RuntimeException e) {
return 2;
}
}
}
@@ -0,0 +1,16 @@
// "Move 'return' to computation of the value of 'n'" "true"
class T {
int f(boolean b) {
int n = -1;
try {
n = 1;
if (b) {
throw new RuntimeException();
}
}
catch (RuntimeException e) {
n = 2;
}
re<caret>turn n;
}
}
@@ -0,0 +1,24 @@
// "Move 'return' to computation of the value of 'n'" "true"
import java.io.*;
class T {
int f(boolean b, boolean c) {
int n = -1;
try {
n = 1;
if (b) throw new IOException();
n = 2;
if (c) throw new RuntimeException();
}
catch (IOException e) {
throw new RuntimeException(e);
}
catch (RuntimeException e) {
return 3;
}
finally {
System.out.println();
}
re<caret>turn n;
}
}
@@ -0,0 +1,24 @@
// "Move 'return' to computation of the value of 'n'" "true"
import java.io.*;
class T {
int f(boolean b, boolean c) {
int n = -1;
try {
n = 1;
if (b) throw new IOException();
n = 2;
if (c) throw new RuntimeException();
}
catch (IOException e) {
throw new RuntimeException(e);
}
catch (RuntimeException e) {
n = 3;
}
finally {
System.out.println();
}
re<caret>turn n;
}
}
@@ -0,0 +1,24 @@
// "Move 'return' to computation of the value of 'n'" "false"
import java.io.*;
class T {
int f(boolean b, boolean c) {
int n = -1;
try {
n = 1;
if (b) throw new IOException();
n = 2;
if (c) throw new RuntimeException();
}
catch (IOException e) {
throw new RuntimeException(e);
}
catch (RuntimeException e) {
n = 3;
}
finally {
n = 4;
}
re<caret>turn n;
}
}
@@ -0,0 +1,24 @@
// "Move 'return' to computation of the value of 'n'" "false"
import java.io.*;
class T {
int f(boolean b, boolean c) {
int n = -1;
try {
n = 1;
if (b) throw new IOException();
n = 2;
if (c) throw new RuntimeException();
}
catch (IOException e) {
throw new RuntimeException(e);
}
catch (RuntimeException e) {
n = 3;
}
finally {
System.out.println(n);
}
re<caret>turn n;
}
}
@@ -0,0 +1,24 @@
// "Move 'return' to computation of the value of 'n'" "true"
import java.io.*;
class T {
int f(boolean b, boolean c) {
int n = -1;
try {
n = 1;
if (b) throw new IOException();
n = 2;
if (c) throw new RuntimeException();
}
catch (IOException e) {
throw new RuntimeException(e);
}
catch (RuntimeException e) {
n = 3;
}
finally {
return 4;
}
re<caret>turn n;
}
}
@@ -0,0 +1,24 @@
// "Move 'return' to computation of the value of 'n'" "true"
import java.io.*;
class T {
int f(boolean b, boolean c, boolean d) {
int n = -1;
try {
n = 1;
if (b) throw new IOException();
n = 2;
if (c) throw new RuntimeException();
}
catch (IOException e) {
throw new RuntimeException(e);
}
catch (RuntimeException e) {
n = 3;
}
finally {
if(d) return 4;
}
re<caret>turn n;
}
}
@@ -0,0 +1,16 @@
// "Move 'return' to computation of the value of 'n'" "true"
class T {
int f(boolean b) {
int n = -1;
try {
n = 1;
if (b) {
throw new RuntimeException();
}
}
catch (RuntimeException e) {
throw new RuntimeException(e);
}
re<caret>turn n;
}
}
@@ -0,0 +1,16 @@
// "Move 'return' to computation of the value of 'n'" "true"
class T {
int f(boolean b) {
int n = -1;
try {
n = 1;
if (b) {
throw new RuntimeException();
}
}
catch (RuntimeException e) {
return 2;
}
re<caret>turn n;
}
}