IDEA-167578 Uncompilable code after convertion forEach -> Loop with generics wildcard

This commit is contained in:
Tagir Valeev
2017-02-02 21:52:14 +03:00
parent 71f67e4a50
commit 2e1c753a6d
3 changed files with 39 additions and 6 deletions
@@ -1,8 +1,6 @@
// "Fix all 'Stream API call chain can be replaced with loop' problems in file" "true"
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Stream;
@@ -19,4 +17,24 @@ public class Main {
System.out.println(s);
}
}
public static <T extends Collection<?>> T test(T collection) {
for (Object o : collection) {
System.out.println(o);
}
return collection;
}
public interface SomeInterface {
Set<? extends SomeInterface> nodes();
default void accept(Visitor visitor) {
for (SomeInterface child : new LinkedHashSet<>(this.nodes())) {
child.accept(visitor);
}
}
interface Visitor { }
}
}
@@ -1,8 +1,6 @@
// "Fix all 'Stream API call chain can be replaced with loop' problems in file" "true"
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Stream;
@@ -15,4 +13,20 @@ public class Main {
List<String> list = Arrays.asList("a", "b");
list.forEach(System.out::println);
}
public static <T extends Collection<?>> T test(T collection) {
collection.forEach(System.out::println);
return collection;
}
public interface SomeInterface {
Set<? extends SomeInterface> nodes();
default void accept(Visitor visitor) {
new LinkedHashSet<>(this.nodes()).forEach(child -> child.accept(visitor));
}
interface Visitor { }
}
}