mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 15:27:45 +07:00
inference: retrieve type from containing call if the corresponding method is not generics (IDEA-151443)
This commit is contained in:
+37
@@ -0,0 +1,37 @@
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
class Main {
|
||||
|
||||
public static void main(String[] args) throws ExecutionException, InterruptedException {
|
||||
Foo foo = first().get();
|
||||
System.out.println(foo.getClass());
|
||||
}
|
||||
|
||||
static CompletableFuture<Foo> first() {
|
||||
return second().thenCompose(maybe -> maybe.map(bar -> CompletableFuture.completedFuture(new Foo()))
|
||||
.orElseGet(() -> CompletableFuture.completedFuture(new FooExt())));
|
||||
}
|
||||
|
||||
static CompletableFuture<Optional<Bar>> second() {
|
||||
return CompletableFuture.completedFuture(Optional.empty());
|
||||
}
|
||||
|
||||
|
||||
static void simplified(final Optional<CompletableFuture<Foo>> future) {
|
||||
future.orElseGet(() -> CompletableFuture.completedFuture(new FooExt()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Foo {
|
||||
}
|
||||
|
||||
class FooExt extends Foo {
|
||||
|
||||
}
|
||||
|
||||
class Bar {
|
||||
}
|
||||
Reference in New Issue
Block a user