A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pmd/pmd/issues/5329 below:

[java] Type inference issue with unknown method ref in call chain · Issue #5329 · pmd/pmd · GitHub

This surfaced as an FP of UnusedPrivateMethod. It is caused by the fact that collect is inferred to Map<Object, List<Item>> and not Map<(*unknown*), List<Item>>.

One of the examples where buildItem(a, b) method is considered as unused:

        List<SummaryDto.ItemDto> items = new ArrayList<>();
        loads.stream()
                .collect(Collectors.groupingBy(Item::getValue))
                .forEach((a, b) -> items.add(buildItem(a, b)));

        private SummaryDto.ItemDto buildItem(BigDecimal a, List<Item> b) {
            return SummaryDto.ItemDto.builder()....build();
        }

In the case of creating the same method without params - there is no issue

        List<SummaryDto.ItemDto> items = new ArrayList<>();
        loads.stream()
                .collect(Collectors.groupingBy(Item::getValue))
                .forEach((a, b) -> items.add(buildItem()));

        private SummaryDto.ItemDto buildItem() {
            return SummaryDto.ItemDto.builder()....build();
        }

Originally posted by @VitaliiIevtushenko in #5184 (comment)


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4