You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import static java.util.stream.Collectors.collectingAndThen;
import java.util.function.Function;
import java.util.stream.Collector;
import java.util.stream.Stream;
public abstract class BiStream<K, V> {
public static <E, K, V> Collector<E, ?, BiStream<K, V>> toBiStream(
Function<? super E, ? extends K> toKey, Function<? super E, ? extends V> toValue) {
return collectingAndThen(toStream(), stream -> from(stream));
}
private static <T> Collector<T, ?, Stream<T>> toStream() {
return null;
}
public static <T, K, V> BiStream<K, V> from(Iterable<T> elements) {
return null;
}
public static <T, K, V> BiStream<K, V> from(Stream<T> stream) {
return null;
}
}
Fails to compile in ecj-4.32 with the following error:
1. ERROR in /Users/rluble/Downloads/BiStream.java (at line 10)
return collectingAndThen(toStream(), stream -> from(stream));
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Type mismatch: cannot convert from Collector<Object,Object,Object> to Collector<E,?,BiStream<K,V>>
This is the result of selecting the wrong overload and incorrectly depending on declaration order.
If the overloads are declared in a different order as in:
import static java.util.stream.Collectors.collectingAndThen;
import java.util.function.Function;
import java.util.stream.Collector;
import java.util.stream.Stream;
public abstract class BiStream<K, V> {
public static <E, K, V> Collector<E, ?, BiStream<K, V>> toBiStream(
Function<? super E, ? extends K> toKey, Function<? super E, ? extends V> toValue) {
return collectingAndThen(toStream(), stream -> from(stream));
}
private static <T> Collector<T, ?, Stream<T>> toStream() {
return null;
}
public static <T, K, V> BiStream<K, V> from(Stream<T> stream) {
return null;
}
public static <T, K, V> BiStream<K, V> from(Iterable<T> elements) {
return null;
}
}
the code compiles.
The text was updated successfully, but these errors were encountered:
The following code:
Fails to compile in ecj-4.32 with the following error:
This is the result of selecting the wrong overload and incorrectly depending on declaration order.
If the overloads are declared in a different order as in:
the code compiles.
The text was updated successfully, but these errors were encountered: