mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
Java inspection: Added lambda expression tests for "Move return to computation" inspection (IDEA-121153)
This commit is contained in:
+17
@@ -0,0 +1,17 @@
|
||||
// "Move 'return' closer to computation of the value of 'n'" "true"
|
||||
class T {
|
||||
interface I {
|
||||
int call();
|
||||
}
|
||||
void f(boolean b) {
|
||||
g(() -> {
|
||||
int n = -1;
|
||||
if (b) return 1;
|
||||
return n;
|
||||
});
|
||||
}
|
||||
|
||||
void g(I i) {
|
||||
i.call();
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// "Move 'return' closer to computation of the value of 'n'" "true"
|
||||
class T {
|
||||
interface I {
|
||||
int call();
|
||||
}
|
||||
void f(boolean b) {
|
||||
g(() -> {
|
||||
int n = -1;
|
||||
while (true) {
|
||||
if (h()) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void g(I i) {
|
||||
i.call();
|
||||
}
|
||||
|
||||
boolean h() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// "Move 'return' closer to computation of the value of 'n'" "true"
|
||||
class T {
|
||||
interface I {
|
||||
int call();
|
||||
}
|
||||
void f(boolean b) {
|
||||
g(() -> {
|
||||
int n = -1;
|
||||
if (b) n = 1;
|
||||
ret<caret>urn n;
|
||||
});
|
||||
}
|
||||
|
||||
void g(I i) {
|
||||
i.call();
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
// "Move 'return' closer to computation of the value of 'n'" "true"
|
||||
class T {
|
||||
interface I {
|
||||
int call();
|
||||
}
|
||||
void f(boolean b) {
|
||||
g(() -> {
|
||||
int n = -1;
|
||||
while (true) {
|
||||
if (h()) {
|
||||
n = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ret<caret>urn n;
|
||||
});
|
||||
}
|
||||
|
||||
void g(I i) {
|
||||
i.call();
|
||||
}
|
||||
|
||||
boolean h() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user