MethodReturnTypeFix: highlight only return statements when method return type doesn't match expected (IDEA-216275)

GitOrigin-RevId: d5f7dc3b03d68d249ba29532b0e8c0555cae60d6
This commit is contained in:
Artemiy Sartakov
2019-07-08 18:53:24 +07:00
committed by intellij-monorepo-bot
parent ba328fd25a
commit 642c65dd11
37 changed files with 167 additions and 217 deletions

View File

@@ -6,7 +6,7 @@ class Test {
return list.stream().flatMap(List::stream).collect(Collectors.toList());
}
private static List<Object> <error descr="Invalid return type">test1</error>(List<List> list) {
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

@@ -26,7 +26,7 @@ public class ConcurrentCollectors {
}
static class Test3 {
static <T, K, D, M1 extends Map<K, D>> C<T, M1> <error descr="Invalid return type">groupingBy</error>(F<M1> f,
static <T, K, D, M1 extends Map<K, D>> C<T, M1> groupingBy(F<M1> f,
C<T, D> c,
BiConsumer<M1, T> consumer) {
return new CImpl<error descr="Cannot infer arguments"><></error>(f, consumer, arg(c.getOp()));

View File

@@ -11,7 +11,7 @@ interface Foo<T> {
}
class Bar {
Foo<List<String>> <error descr="Invalid return type">transform</error>(final Foo<? extends String> foo) {
Foo<List<String>> transform(final Foo<? extends String> foo) {
<error descr="Incompatible types. Found: 'Foo<? extends java.util.List<? extends java.lang.String>>', required: 'Foo<java.util.List<java.lang.String>>'">return foo
.map(v2 -> tuple(v2))
.onClose();</error>

View File

@@ -3,7 +3,7 @@ import java.util.Map;
import java.util.stream.Collectors;
class MyTest {
static Map<String, Meeting> <error descr="Invalid return type">getMeetingsById</error>(List<Meeting> meetings){
static Map<String, Meeting> getMeetingsById(List<Meeting> meetings){
return <error descr="Incompatible types. Found: 'java.util.Map<java.lang.String,java.util.List<Meeting>>', required: 'java.util.Map<java.lang.String,Meeting>'">meetings.stream()
.collect(Collectors.groupingBy(Meeting::getId));</error>
}