Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[java] Type inference issue with unknown method ref in call chain #5329

Closed
oowekyala opened this issue Nov 14, 2024 · 0 comments · Fixed by #5330
Closed

[java] Type inference issue with unknown method ref in call chain #5329

oowekyala opened this issue Nov 14, 2024 · 0 comments · Fixed by #5330
Milestone

Comments

@oowekyala
Copy link
Member

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants