IDEA-178434 "Unwrap 'if' statement" produces incompilable code if variable declared in the if body shadows the outer scope variable

This commit is contained in:
peter
2017-10-13 21:17:37 +02:00
parent f80732a7f6
commit 609eea57ac
3 changed files with 39 additions and 24 deletions
@@ -0,0 +1,13 @@
// "Unwrap 'if' statement" "true"
class X {
StringBuilder str = new StringBuilder();
void test(@org.jetbrains.annotations.NotNull String x) {
<caret>{
String str = x.trim();
System.out.println(str);
}
str.append("foo");
}
}
@@ -0,0 +1,13 @@
// "Unwrap 'if' statement" "true"
class X {
StringBuilder str = new StringBuilder();
void test(@org.jetbrains.annotations.NotNull String x) {
if(x != <caret>null) {
String str = x.trim();
System.out.println(str);
}
str.append("foo");
}
}