method references: don't fall to raw substitutor with second search (IDEA-180615)

This commit is contained in:
Anna.Kozlova
2017-10-16 12:10:36 +02:00
parent 10228db37c
commit 465458db4d
9 changed files with 98 additions and 77 deletions

View File

@@ -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>
}
}

View File

@@ -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);
}
}

View File

@@ -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));
}
}