mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 03:13:40 +07:00
IDEA-167578 Uncompilable code after convertion forEach -> Loop with generics wildcard
This commit is contained in:
+21
-3
@@ -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 { }
|
||||
}
|
||||
}
|
||||
+17
-3
@@ -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 { }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user