MethodReturnTypeFix: updated fix to change method return type based on return statements in method body (IDEA-216275)

GitOrigin-RevId: e97990950039123c8c41921a71342b8ed60afdee
This commit is contained in:
Artemiy Sartakov
2019-07-04 09:02:24 +03:00
committed by intellij-monorepo-bot
parent 52aa1ae553
commit 42d733a694
42 changed files with 381 additions and 55 deletions
@@ -0,0 +1,11 @@
// "Make 'm' return 'java.util.AbstractList<java.lang.Object>' or predecessor" "true"
import java.util.*;
class Test {
AbstractList<Object> m(boolean b) {
if (b) return new ArrayList<>();
return new LinkedList<>();
}
}
@@ -0,0 +1,10 @@
// "Make 'm' return 'java.lang.Integer' or predecessor" "true"
class Test {
Integer m(boolean b) {
if (b) return null;
return 42;
}
}
@@ -0,0 +1,9 @@
// "Make 'm' return 'int'" "true"
class Test {
int m() {
return 42;
}
}
@@ -0,0 +1,8 @@
// "Make 'm' return 'void'" "true"
class Test {
void m() {
}
}
@@ -0,0 +1,9 @@
// "Make 'm' return 'double'" "true"
class Test {
double m(boolean b) {
if (b) return 42;
return 10.0;
}
}
@@ -2,7 +2,7 @@
class Test {
<caret><selection>Object</selection> foo() {
Object foo() {
return null;
}
}
@@ -0,0 +1,11 @@
// "Make 'm' return 'java.util.AbstractList<java.lang.Object>' or predecessor" "true"
import java.util.*;
class Test {
void <caret>m(boolean b) {
if (b) return new ArrayList<>();
return new LinkedList<>();
}
}
@@ -0,0 +1,10 @@
// "Make 'm' return 'java.lang.Integer' or predecessor" "true"
class Test {
void <caret>m(boolean b) {
if (b) return null;
return 42;
}
}
@@ -0,0 +1,9 @@
// "Make 'm' return 'int'" "true"
class Test {
void <caret>m() {
return 42;
}
}
@@ -0,0 +1,8 @@
// "Make 'm' return 'void'" "true"
class Test {
int <caret>m() {
}
}
@@ -0,0 +1,9 @@
// "Make 'm' return 'double'" "true"
class Test {
<caret>m(boolean b) {
if (b) return 42;
return 10.0;
}
}