Files
Tagir Valeev d8e08c17bb [java-highlighting] Improve error messages around inapplicable method reference
Fixes IDEA-362351 An Incorrect Error warning "Non-static methods cannot be referenced from a static context"
Fixes IDEA-173183 Wrong error message for method reference
Improves IDEA-208532 Incorrect Inspect code error in lambda expression method reference

GitOrigin-RevId: 8f7a17688eaa1aba72bbccd45395967656108668
2024-11-22 15:34:30 +00:00

22 lines
855 B
Java

import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public class Test
{
public static void main(String[] args)
{
Map<Long, Long> longLongMap = new HashMap();
List<Map.Entry<Long,Long>> entryListWithError = longLongMap.entrySet().stream()
.sorted<error descr="'sorted(java.util.Comparator<? super java.util.Map.Entry<java.lang.Long,java.lang.Long>>)' in 'java.util.stream.Stream' cannot be applied to '(java.util.Comparator<T>)'">(Comparator.comparing(Map.Entry::getValue).reversed())</error>
.limit(10)
.collect(Collectors.toList());
List<Map.Entry<Long,Long>> entryListWithoutError = longLongMap.entrySet().stream()
.sorted(Comparator.comparing(Map.Entry::getValue))
.limit(10)
.collect(Collectors.toList());
}
}