mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-15 11:58:18 +07:00
IDEA-177238 QuickFix for "Casting ... to ... may produce ClassCastException"
GitOrigin-RevId: 000f7b616edb300b98cdefe04d954c5023365f8c
This commit is contained in:
committed by
intellij-monorepo-bot
parent
b9cc2e27fa
commit
c78392d802
+9
@@ -0,0 +1,9 @@
|
||||
// "Replace 'Integer' with 'String' in cast" "true"
|
||||
import java.util.*;
|
||||
|
||||
class X {
|
||||
void test() {
|
||||
Object x = "foo";
|
||||
System.out.println((String)x);
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace 'LinkedList<String>' with 'ArrayList<String>' in cast" "true"
|
||||
import java.util.*;
|
||||
|
||||
class X {
|
||||
void test(List<String> x) {
|
||||
if (x instanceof ArrayList) {
|
||||
AbstractList<String> list = (ArrayList<String>)x;
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace 'Integer' with 'Number' in cast" "true"
|
||||
import java.util.*;
|
||||
|
||||
class X {
|
||||
void test(Object x) {
|
||||
if (x instanceof Integer || x instanceof Long) {
|
||||
System.out.println(((Number)x).longValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Replace 'Integer' with 'String' in cast" "true"
|
||||
import java.util.*;
|
||||
|
||||
class X {
|
||||
void test() {
|
||||
Object x = "foo";
|
||||
System.out.println((<caret>Integer)x);
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace 'LinkedList<String>' with 'ArrayList<String>' in cast" "true"
|
||||
import java.util.*;
|
||||
|
||||
class X {
|
||||
void test(List<String> x) {
|
||||
if (x instanceof ArrayList) {
|
||||
AbstractList<String> list = (LinkedList<caret><String>)x;
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace 'Integer' with 'Number' in cast" "true"
|
||||
import java.util.*;
|
||||
|
||||
class X {
|
||||
void test(Object x) {
|
||||
if (x instanceof Integer || x instanceof Long) {
|
||||
System.out.println(((<caret>Integer)x).longValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Fix all 'Constant conditions & exceptions' problems in file" "false"
|
||||
import java.util.*;
|
||||
|
||||
class X {
|
||||
void test(Object x) {
|
||||
if (!(x instanceof Number)) {
|
||||
System.out.println(((<caret>Integer)x).longValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user