mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IG: ignore casting class types to primitive (IDEA-170332)
This commit is contained in:
+2
-1
@@ -121,6 +121,7 @@ public class UnnecessaryExplicitNumericCastInspection extends BaseInspection {
|
||||
}
|
||||
final PsiType operandType = operand.getType();
|
||||
if (castType.equals(operandType) || isPrimitiveNumericCastNecessary(expression)) {
|
||||
// equal types is caught by "Redundant type cast" inspection
|
||||
return;
|
||||
}
|
||||
final PsiTypeElement typeElement = expression.getCastType();
|
||||
@@ -140,7 +141,7 @@ public class UnnecessaryExplicitNumericCastInspection extends BaseInspection {
|
||||
return true;
|
||||
}
|
||||
final PsiType operandType = operand.getType();
|
||||
if (operandType == null) {
|
||||
if (!(operandType instanceof PsiPrimitiveType)) {
|
||||
return true;
|
||||
}
|
||||
PsiElement parent = expression.getParent();
|
||||
|
||||
+14
@@ -88,3 +88,17 @@ enum Numeric {
|
||||
|
||||
Numeric(byte b) {}
|
||||
}
|
||||
class S {
|
||||
|
||||
static void doSomething() {
|
||||
// V --- this cast is reported as unnecessary
|
||||
if ( (int) whatever() < 0 ) {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static <T> T whatever() {
|
||||
return (T) (Object) 0;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user