IDEA-229892 Side-effect extractor: adapt for patterns

GitOrigin-RevId: 393c52e12ef82e5ced624edd59416ea6704d8e6b
This commit is contained in:
Tagir Valeev
2020-02-10 11:03:00 +00:00
committed by intellij-monorepo-bot
parent ce4fd32826
commit 7a1862550e
13 changed files with 114 additions and 10 deletions
@@ -0,0 +1,6 @@
// "Remove 'if' statement" "true"
class X {
void test() {
Object obj = "Hello from pattern matching";
}
}
@@ -0,0 +1,8 @@
// "Remove 'if' statement extracting side effects" "true"
class X {
void test() {
Object obj = "Hello from pattern matching";
String s = (String) obj;
System.out.println(s);
}
}
@@ -0,0 +1,11 @@
// "Remove 'if' statement extracting side effects" "true"
class X {
void test() {
Object obj = "Hello from pattern matching";
String s = getString();
System.out.println(s);
System.out.println(s);
}
native @org.jetbrains.annotations.NotNull String getString();
}
@@ -0,0 +1,9 @@
// "Remove 'if' statement" "true"
class X {
void test() {
Object obj = "Hello from pattern matching";
if (obj instanceof<caret> Integer i) {
System.out.println(i);
}
}
}
@@ -0,0 +1,8 @@
// "Remove 'if' statement extracting side effects" "true"
class X {
void test() {
Object obj = "Hello from pattern matching";
if (!(obj instanceof <caret>String s)) return;
System.out.println(s);
}
}
@@ -0,0 +1,11 @@
// "Remove 'if' statement extracting side effects" "true"
class X {
void test() {
Object obj = "Hello from pattern matching";
if (!(getString() instanceof <caret>String s)) return;
System.out.println(s);
System.out.println(s);
}
native @org.jetbrains.annotations.NotNull String getString();
}