mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
RedundantCastUtil: report safe widening primitive casts
Fixes IDEA-154832 IDEA add unnecessary cast to double on method inline GitOrigin-RevId: 1e8dbd1466f74bdab9584a860f4e188b025fba1c
This commit is contained in:
committed by
intellij-monorepo-bot
parent
505bdd1c87
commit
bfde8b00af
@@ -0,0 +1,18 @@
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
class A {
|
||||
double widen(int x) {
|
||||
return (<warning descr="Casting 'x' to 'double' is redundant">double</warning>) x;
|
||||
}
|
||||
|
||||
double widenDataLoss(long x) {
|
||||
return (double) x;
|
||||
}
|
||||
|
||||
void call(short a, byte b, long c) {
|
||||
widen((<warning descr="Casting 'a' to 'int' is redundant">int</warning>)a);
|
||||
widen((<warning descr="Casting 'b' to 'int' is redundant">int</warning>)b);
|
||||
widen((int)c);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
class UnnecessaryDoubleCast {
|
||||
public void check() {
|
||||
<caret>eq(25, 25.49);
|
||||
}
|
||||
|
||||
private static void eq(double expected, double actual) {
|
||||
assertDoubleEquals(expected, actual);
|
||||
}
|
||||
|
||||
public static void assertDoubleEquals(double v, double v2) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
class UnnecessaryDoubleCast {
|
||||
public void check() {
|
||||
assertDoubleEquals(25, 25.49);
|
||||
}
|
||||
|
||||
public static void assertDoubleEquals(double v, double v2) {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user