@@ -1192,17 +1192,17 @@ public void testGH4033() {
11921192 """
11931193 import java.util.Collection;
11941194 import java.util.Iterator;
1195-
1195+
11961196 public class Snippet {
11971197 interface Apple {}
11981198 interface Banana<T1, T2> {}
11991199 interface Smoothie<T extends Apple, M extends Apple> extends Banana<T, String> {}
1200-
1200+
12011201 public static void main(String[] args) {
12021202 Collection<Smoothie<? extends Apple, ? extends Apple>> c = null;
12031203 method(c);
12041204 }
1205-
1205+
12061206 static final <S extends Banana<? extends T, ?>, T> Iterator<T> method(
12071207 Collection<S> c) {
12081208 return null;
@@ -1235,6 +1235,63 @@ public static void main(String[] args) {
12351235 });
12361236}
12371237
1238+ public void testGH4003 () {
1239+ if (this .complianceLevel < ClassFileConstants .JDK10 )
1240+ return ; // uses 'var'
1241+ runConformTest (new String [] {
1242+ "EclipseCompilerBugReproducer.java" ,
1243+ """
1244+ import java.util.List;
1245+ import java.util.concurrent.CompletableFuture;
1246+ import java.util.concurrent.CompletionStage;
1247+ import java.util.function.Function;
1248+ import java.util.function.Supplier;
1249+
1250+ public class EclipseCompilerBugReproducer {
1251+
1252+ public static final class Mono<T> {
1253+
1254+ public static <T> Mono<T> fromFuture(CompletionStage<? extends T> stage) {
1255+ return new Mono<>();
1256+ }
1257+
1258+ public static <T> Mono<T> fromFuture(
1259+ Supplier<? extends CompletionStage<? extends T>> stageSupplier) {
1260+ return new Mono<>();
1261+ }
1262+
1263+ public <R> Mono<R> flatMap(Function<? super T, Mono<? extends R>> mapper) { return new Mono<>(); }
1264+ public <R> Mono<R> map(Function<? super T, ? extends R> mapper) { return new Mono<>(); }
1265+ public List<T> collectList() { return List.of(); }
1266+ public T block() { return null; }
1267+ }
1268+
1269+ static final class Bucket {
1270+ CompletionStage<String> get(String id) {
1271+ return CompletableFuture.completedFuture("value-for-" + id);
1272+ }
1273+ }
1274+
1275+ /* ---------------------------------------------------------------------- */
1276+ /* Reproducer */
1277+ /* ---------------------------------------------------------------------- */
1278+ public static void main(String[] args) {
1279+
1280+ var ids = List.of("a", "b", "c");
1281+ var bucket = new Bucket();
1282+
1283+ ids.stream()
1284+ .flatMap(id ->
1285+ Mono.fromFuture(() -> bucket.get(id)) // <-- fails in Eclipse
1286+ .map(String::toUpperCase)
1287+ .collectList()
1288+ .stream())
1289+ .forEach(System.out::println);
1290+ }
1291+ }
1292+ """
1293+ });
1294+ }
12381295public static Class <GenericsRegressionTest_9 > testClass () {
12391296 return GenericsRegressionTest_9 .class ;
12401297}
0 commit comments