IDEA-146770 Suggest Math.toIntExact to convert long to int

This commit is contained in:
Dmitry Batkovich
2015-10-28 19:55:14 +03:00
parent dc3074b0cd
commit 713a1289c7
17 changed files with 281 additions and 1 deletions
@@ -0,0 +1,11 @@
// "Wrap using 'Math.toIntExact()'" "true"
public class Test {
void m(long l) {
int i = 10;
i = Math.toIntExact(l);
}
}
@@ -0,0 +1,12 @@
// "Wrap 2nd parameter using 'Math.toIntExact()'" "true"
public class Test {
void longMethod(int k, int thisIsInt) {
}
void m(long ll) {
longMethod(13, Math.toIntExact(ll));
}
}
@@ -0,0 +1,12 @@
// "Wrap parameter using 'Math.toIntExact()'" "true"
public class Test {
void m(int i) {
}
void method() {
m(Math.toIntExact(10L));
}
}
@@ -0,0 +1,10 @@
// "Wrap using 'Math.toIntExact()'" "true"
public class Test {
void m() {
int i = Math.toIntExact(Long.valueOf(123));
}
}
@@ -0,0 +1,11 @@
// "Wrap using 'Math.toIntExact()'" "true"
public class Test {
void m(long l) {
int i = 10;
i = l<caret>;
}
}
@@ -0,0 +1,12 @@
// "Wrap 2nd parameter using 'Math.toIntExact()'" "true"
public class Test {
void longMethod(int k, int thisIsInt) {
}
void m(long ll) {
longMethod(13, l<caret>l);
}
}
@@ -0,0 +1,12 @@
// "Wrap parameter using 'Math.toIntExact()'" "true"
public class Test {
void m(int i) {
}
void method() {
m(10<caret>L);
}
}
@@ -0,0 +1,10 @@
// "Wrap using 'Math.toIntExact()'" "true"
public class Test {
void m() {
int i = Long.valu<caret>eOf(123);
}
}