stream api: do not collapse loops when body is not throws compatible (IDEA-125541)

This commit is contained in:
Anna Kozlova
2014-05-26 15:35:49 +04:00
parent 972c75d275
commit 32fe2746f9
3 changed files with 57 additions and 2 deletions
@@ -0,0 +1,19 @@
// "Replace with collect" "false"
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class ForEachTest {
interface A {
String ii() throws IOException;
}
private List<A> reqs;
public ForEachTest () throws IOException {
List<String> result = new ArrayList<>();
for(A val : re<caret>qs) {
result.add(val.ii());
}
}
}
@@ -0,0 +1,17 @@
// "Replace with forEach" "false"
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.List;
class Test {
private List<byte[]> reqs;
public ForEachTest () throws IOException {
DataOutputStream req = new DataOutputStream(new ByteArrayOutputStream());
for(byte[] val : r<caret>eqs) {
req.write(val);
}
}
}