Skip to content

[java] Allow lambdas with unresolved target types to succeed inference#5339

Merged
adangel merged 8 commits intopmd:mainfrom
oowekyala:typeres-fix-inference-issue-mref
Nov 22, 2024
Merged

[java] Allow lambdas with unresolved target types to succeed inference#5339
adangel merged 8 commits intopmd:mainfrom
oowekyala:typeres-fix-inference-issue-mref

Conversation

@oowekyala
Copy link
Copy Markdown
Member

@oowekyala oowekyala commented Nov 15, 2024

This prevents failures in code that uses lambdas but doesn't have a full classpath. In particular, UnusedPrivateMethod used to report failures in this case.

Describe the PR

Related issues

Ready?

  • Added unit tests for fixed bug/feature
  • Passing all unit tests
  • Complete build ./mvnw clean verify passes (checked automatically by github actions)
  • Added (in-code) documentation (if needed)

@oowekyala oowekyala marked this pull request as ready for review November 15, 2024 13:53
@oowekyala oowekyala added the in:type-resolution Affects the type resolution code label Nov 15, 2024
@oowekyala oowekyala marked this pull request as draft November 15, 2024 13:55
@oowekyala oowekyala marked this pull request as ready for review November 15, 2024 14:44
@ghost
Copy link
Copy Markdown

ghost commented Nov 15, 2024

1 Message
📖 Compared to main:
This changeset changes 0 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 0 errors and 0 configuration errors.
Download full report as build artifact
Compared to main:
This changeset changes 0 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 0 errors and 0 configuration errors.
Download full report as build artifact
Compared to main:
This changeset changes 0 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 0 errors and 0 configuration errors.
Download full report as build artifact
Compared to main:
This changeset changes 0 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 0 errors and 0 configuration errors.
Download full report as build artifact

Generated by 🚫 Danger

@adangel adangel added this to the 7.8.0 milestone Nov 17, 2024
Copy link
Copy Markdown
Member

@adangel adangel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

private void foo(int y, FunctionalItf x) {
}
private void foo(FunctionalItf x) {
return SummaryDto.ItemDto.builder().build();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll remove this return, as foo is void.

return SummaryDto.ItemDto.builder().build();
}
private <T extends FunctionalItf> T bar(T x) {
return SummaryDto.ItemDto.builder().build();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll just do return x; here to avoid bringing SummaryDto etc. into context (which are also unresolved).

@adangel adangel merged commit 316367d into pmd:main Nov 22, 2024
adangel added a commit that referenced this pull request Nov 22, 2024
adangel added a commit that referenced this pull request Nov 22, 2024
#5339)

Merge pull request #5339 from oowekyala:typeres-fix-inference-issue-mref
@oowekyala oowekyala deleted the typeres-fix-inference-issue-mref branch November 22, 2024 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in:type-resolution Affects the type resolution code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[java] Unresolved target type for lambdas make overload resolution fail

2 participants