mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 15:09:39 +07:00
method references: don't fall to raw substitutor with second search (IDEA-180615)
This commit is contained in:
@@ -5,4 +5,8 @@ class Test {
|
||||
private static List<Object> test(List<List> list) {
|
||||
return list.stream().flatMap(List::stream).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private static List<Object> test1(List<List> list) {
|
||||
<error descr="Incompatible types. Found: 'java.lang.Object', required: 'java.util.List<java.lang.Object>'">return list.stream().flatMap(l -> l.stream()).collect(Collectors.toList());</error>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
class Thing<T> {
|
||||
|
||||
private final T value;
|
||||
|
||||
public Thing(T value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public <U> Thing<U> flatMap(Function<T, Thing<U>> f) {
|
||||
return f.apply(value);
|
||||
}
|
||||
|
||||
public <X extends Throwable> void exceptionMethod(Supplier<X> xSupplier) throws X { }
|
||||
|
||||
void m(final Thing<Integer> integer){
|
||||
integer.flatMap(s -> new Thing(s)).<error descr="Unhandled exception: java.lang.Throwable">exceptionMethod(IllegalStateException::new);</error>
|
||||
integer.flatMap(Thing::new).exceptionMethod(IllegalStateException::new);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
class MyTest {
|
||||
|
||||
public static <T, V> void map(Collection<? extends T> iterable,
|
||||
Function<T, V> mapping) {}
|
||||
|
||||
interface StubElement<P extends String> {
|
||||
P getPsi();
|
||||
}
|
||||
|
||||
void foo(List<StubElement> stubs) {
|
||||
map(stubs, StubElement::getPsi);
|
||||
}
|
||||
|
||||
void bar(Stream<StubElement> stream) {
|
||||
stream.<String>map(StubElement::getPsi).map(s -> s.substring(0));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user