mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 07:40:42 +07:00
IntegerMultiplicationImplicitCastToLong: added quick-fix (IDEA-206024)
This commit is contained in:
+13
@@ -0,0 +1,13 @@
|
||||
// "Fix all 'Integer multiplication or shift implicitly cast to long' problems in file" "true"
|
||||
class Test {
|
||||
void test(int a, int b) {
|
||||
long c = a * 2L;
|
||||
long d = 2L * a;
|
||||
long d1 = -2L * a;
|
||||
long e = (long) a * b;
|
||||
long f = (long) a * b * 2; // should be converted to (long) a * b * 2 or 2L * a * b (but not a*b*2L: in this case a*b would still be integer)
|
||||
long g = (long) a << 2;
|
||||
long h = 2L << a;
|
||||
long i = (2L) * a;
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Fix all 'Integer multiplication or shift implicitly cast to long' problems in file" "true"
|
||||
class Test {
|
||||
|
||||
void test (int i1, int i2, int i3) {
|
||||
long a = (long) (((long) i1 * i2) * i3);
|
||||
long b = (int) ((i1 * i2) * i3); // shouldn't convert because result is still casted to int
|
||||
long c = ((long) (int) i1 * i2 * i3);
|
||||
long d = ((long) i1 * i2 * i3); // fix is not needed at all
|
||||
long e = (long) ((long) i1 * i2);
|
||||
long f = (i2) * (long) i1; // fix is not needed at all
|
||||
long g = (long) i1 * ((long) i2 * i3);
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// "Fix all 'Integer multiplication or shift implicitly cast to long' problems in file" "true"
|
||||
class Test {
|
||||
void test(int a, int b) {
|
||||
long c = a * ((long) a * b);
|
||||
long d = (a * (b * (a * (b * 2L)));
|
||||
long e = -(-a * -((long) -a * -b));
|
||||
long f = a * ((a == 2) ? (long) b * a : a);
|
||||
long g = a + (a + ((long) (a + b) * (a + b)));
|
||||
long h = (long) a << (a * b);
|
||||
long i = ((long) a * b) << (b * a);
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Fix all 'Integer multiplication or shift implicitly cast to long' problems in file" "true"
|
||||
class Test {
|
||||
void test(int a, int b) {
|
||||
long c = <caret>a * 2;
|
||||
long d = 2 * a;
|
||||
long d1 = -2 * a;
|
||||
long e = a * b;
|
||||
long f = a * b * 2; // should be converted to (long) a * b * 2 or 2L * a * b (but not a*b*2L: in this case a*b would still be integer)
|
||||
long g = a << 2;
|
||||
long h = 2 << a;
|
||||
long i = (2) * a;
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Fix all 'Integer multiplication or shift implicitly cast to long' problems in file" "true"
|
||||
class Test {
|
||||
|
||||
void test (int i1, int i2, int i3) {
|
||||
long a = (long) ((<caret>i1 * i2) * i3);
|
||||
long b = (int) ((i1 * i2) * i3); // shouldn't convert because result is still casted to int
|
||||
long c = ((int) i1 * i2 * i3);
|
||||
long d = ((long) i1 * i2 * i3); // fix is not needed at all
|
||||
long e = (long) (i1 * i2);
|
||||
long f = (i2) * (long) i1; // fix is not needed at all
|
||||
long g = (long) i1 * (i2 * i3);
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// "Fix all 'Integer multiplication or shift implicitly cast to long' problems in file" "true"
|
||||
class Test {
|
||||
void test(int a, int b) {
|
||||
long c = a * (<caret>a * b);
|
||||
long d = (a * (b * (a * (b * 2)));
|
||||
long e = -(-a * -(-a * -b));
|
||||
long f = a * ((a == 2) ? b * a : a);
|
||||
long g = a + (a + ((a + b) * (a + b)));
|
||||
long h = a << (a * b);
|
||||
long i = (a * b) << (b * a);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user