import java.util.Map;
import java.util.function.Function;
public class Pairs<T> {
public <V> void addMapEntries(Function<T, Map<String, V>> extractor) {
add(extractor.andThen(Map::entrySet), Map.Entry::getKey, Map.Entry::getValue);
// add(extractor.andThen((Map<String, V> map) -> map.entrySet()), Map.Entry::getKey, Map.Entry::getValue);
}
public <E> void add(Function<T, Iterable<E>> elementsExtractor, PairExtractor<E> pairExtractor) {
add(elementsExtractor, pairExtractor::getName, pairExtractor::getValue);
}
public <E, V> void add(Function<T, Iterable<E>> elementsExtractor, Function<E, String> nameExtractor,
Function<E, V> valueExtractor) {
}
interface PairExtractor<E> {
<N> N getName(E element);
<V> V getValue(E element);
static <T> PairExtractor<T> of(Function<T, ?> nameExtractor, Function<T, ?> valueExtractor) {
return new PairExtractor<>() {
@Override
@SuppressWarnings("unchecked")
public <N> N getName(T instance) {
return (N) nameExtractor.apply(instance);
}
@Override
@SuppressWarnings("unchecked")
public <V> V getValue(T instance) {
return (V) valueExtractor.apply(instance);
}
};
}
}
}
The issue can’t be reproduced in Eclipse 4.38. Looks like that it has been introduced with 22dc3e1
The following code is a simplified class from the spring-boot project - https://github.com/spring-projects/spring-boot/blob/main/core/spring-boot/src/main/java/org/springframework/boot/logging/structured/ContextPairs.java
JDT incorrectly displays four errors on https://github.com/spring-projects/spring-boot/blob/25ed44368a47012cf9d753e97a8578409d999671/core/spring-boot/src/main/java/org/springframework/boot/logging/structured/ContextPairs.java#L141
The issue can’t be reproduced in Eclipse 4.38. Looks like that it has been introduced with 22dc3e1