ConstantConditionalExpressionInspection: add cast if necessary when type changes

Fixes IDEA-194648 Simpler expression auto-fix results in different code
This commit is contained in:
Tagir Valeev
2018-06-29 15:37:46 +07:00
parent 21ca5b6566
commit 04df6bad09
8 changed files with 85 additions and 11 deletions
@@ -0,0 +1,7 @@
// "Simplify" "true"
class Test {
String test(String foo) {
/*always false?*/
return null;
}
}
@@ -0,0 +1,6 @@
// "Simplify" "true"
class Test {
int test(int a, int b) {
return a;
}
}
@@ -0,0 +1,7 @@
// "Simplify" "true"
class Test {
public static void main(String[] args) {
int i = 0;
System.out.println((int) 'x');
}
}
@@ -0,0 +1,6 @@
// "Simplify" "true"
class Test {
String test(String foo) {
return (false/*always false?*/) ? foo<caret> : null;
}
}
@@ -0,0 +1,6 @@
// "Simplify" "true"
class Test {
int test(int a, int b) {
return true<caret>?a:b;
}
}
@@ -0,0 +1,7 @@
// "Simplify" "true"
class Test {
public static void main(String[] args) {
int i = 0;
System.out.println(false <caret>? i : 'x');
}
}