Java: Don't delete class cast when deleting unused variable (IDEA-181346)

This commit is contained in:
Pavel Dolgov
2017-11-10 14:36:04 +03:00
parent 54b5cce0db
commit 4c3dfe6001
5 changed files with 54 additions and 5 deletions
@@ -0,0 +1,10 @@
// "Remove variable 'c'" "true"
class C {
String s;
void foo(Object o) {
if (o instanceof C) {
String t = ((C) o).s;
}
}
}
@@ -0,0 +1,8 @@
// "Remove variable 'n'" "true"
class C {
void foo(Object o) {
if (o instanceof Integer) {
int i = (Integer) o + 1;
}
}
}
@@ -0,0 +1,11 @@
// "Remove variable 'c'" "true"
class C {
String s;
void foo(Object o) {
if (o instanceof C) {
C c<caret>;
String t = (c = (C) o).s;
}
}
}
@@ -0,0 +1,9 @@
// "Remove variable 'n'" "true"
class C {
void foo(Object o) {
if (o instanceof Integer) {
Integer n<caret>;
int i = (n = (Integer) o) + 1;
}
}
}