mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
Java: Don't extract method where it's not safe because of nullable result (IDEA-167391)
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
class C {
|
||||
private int[] list;
|
||||
|
||||
private int find(int id) {
|
||||
Integer n = newMethod(id);
|
||||
if (n != null) return n;
|
||||
throw new RuntimeException();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Integer newMethod(int id) {
|
||||
for (int n : list) {
|
||||
if (n == id) {
|
||||
return n <= 0 ? 0 : n;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user