mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-01 10:48:09 +07:00
StreamToLoop: disallow peek which cannot finish normally as the result will not be compilable
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.LongSummaryStatistics;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
public class Main {
|
||||
public static int test(List<String> list) {
|
||||
@@ -25,6 +26,12 @@ public class Main {
|
||||
return stat;
|
||||
}
|
||||
|
||||
void peekThrows() {
|
||||
final int sum = IntStream.of(1, 2, 3, 4).peek(x -> {
|
||||
throw new RuntimeException();
|
||||
}).reduce(0, (l, r) -> l + r);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(test(Arrays.asList("aaa", "b", "cc", "dddd")));
|
||||
System.out.println(testSummaryStatistics(Arrays.asList("aaa", "b", "cc", "dddd")));
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
public class Main {
|
||||
public static int test(List<String> list) {
|
||||
@@ -12,6 +13,12 @@ public class Main {
|
||||
return list.stream().peek(s -> System.out.println(s)).mapToLong(l -> l.length()).summaryStatistics();
|
||||
}
|
||||
|
||||
void peekThrows() {
|
||||
final int sum = IntStream.of(1, 2, 3, 4).peek(x -> {
|
||||
throw new RuntimeException();
|
||||
}).reduce(0, (l, r) -> l + r);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(test(Arrays.asList("aaa", "b", "cc", "dddd")));
|
||||
System.out.println(testSummaryStatistics(Arrays.asList("aaa", "b", "cc", "dddd")));
|
||||
|
||||
Reference in New Issue
Block a user