mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-10 18:09:38 +07:00
StreamToLoop: disable in this()/super() constructor invocation as we cannot generate statements before this/super call.
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
// "Replace Stream API chain with loop" "true"
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.Objects;
|
||||
|
||||
public class Main {
|
||||
Main(boolean b) {}
|
||||
|
||||
void test(boolean b) {}
|
||||
|
||||
static class Child extends Main {
|
||||
// cannot replace as replacement would generate a statement before "super" call
|
||||
Child() {
|
||||
super(false);
|
||||
boolean found = false;
|
||||
for (String s : Arrays.asList("a", "b", "c")) {
|
||||
if (Objects.nonNull(s)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
super.test(found);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// "Replace Stream API chain with loop" "false"
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import java.util.Objects;
|
||||
|
||||
public class Main {
|
||||
Main(boolean b) {}
|
||||
|
||||
static class Child extends Main {
|
||||
// cannot replace as replacement would generate a statement before "super" call
|
||||
Child() {
|
||||
super(Stream.of("a", "b", "c").an<caret>yMatch(Objects::nonNull));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// "Replace Stream API chain with loop" "true"
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import java.util.Objects;
|
||||
|
||||
public class Main {
|
||||
Main(boolean b) {}
|
||||
|
||||
void test(boolean b) {}
|
||||
|
||||
static class Child extends Main {
|
||||
// cannot replace as replacement would generate a statement before "super" call
|
||||
Child() {
|
||||
super(false);
|
||||
super.test(Stream.of("a", "b", "c").an<caret>yMatch(Objects::nonNull));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user