IDEA-38591 (Can't use "Create Local Var from instanceof" intention on multiple 'instanceof' with &&)

This commit is contained in:
Bas Leijdekkers
2016-03-24 15:36:14 +01:00
parent 82574ce52c
commit af3365744c
11 changed files with 61 additions and 32 deletions
@@ -2,7 +2,7 @@
class C {
void f(Object o) {
if (o instanceof String) {
String s = (String) o;
String o1 = (String) o;
<caret>
o = "";
}
@@ -0,0 +1,10 @@
// "Insert '(String)o' declaration" "true"
class C {
void f(Object o, Object f) {
if (o instanceof String) {
Float s = 1f;
String o1 = (String) o;
<caret>
}
}
}
@@ -4,7 +4,7 @@ import java.io.IOException;
class C {
void f(Object o) {
if (o instanceof IOException) {
IOException ioException = (IOException) o;
IOException o1 = (IOException) o;
}
@@ -2,7 +2,7 @@
public abstract class A {
public void getNodeElements(Object parent) {
if (!(parent instanceof NodeInfo)) return;
NodeInfo nodeInfo = (NodeInfo) parent;
NodeInfo parent1 = (NodeInfo) parent;
<caret>
}
@@ -2,7 +2,7 @@
class C {
void f(Object o, Object f) {
if (o instanceof String && f == null) {
String s = (String) o;
String o1 = (String) o;
<caret>
}
@@ -3,7 +3,7 @@ class C {
void f(Object o, Object f) {
if (o instanceof String) {//todo comment
String s = (String) o;
String o1 = (String) o;
}
}
@@ -0,0 +1,10 @@
// "Insert '(String)f' declaration" "true"
class C {
void f(Object o, Object f) {
if (o instanceof String && f instanceof String) {
String s = (String) o;
String f1 = (String) f;
<caret>
}
}
}
@@ -2,7 +2,7 @@
class C {
void f(Object o) {
if (o instanceof Runnable) {
Runnable runnable = (Runnable) o;
Runnable o1 = (Runnable) o;
<caret>
}
}
@@ -0,0 +1,8 @@
// "Insert '(String)o' declaration" "true"
class C {
void f(Object o, Object f) {
if (<caret>o instanceof String) {
Float s = 1f;
}
}
}
@@ -0,0 +1,8 @@
// "Insert '(String)f' declaration" "true"
class C {
void f(Object o, Object f) {
if (o instanceof String && f<caret> instanceof String) {
String s = (String) o;
}
}
}