Skip to content

Conversation

@oowekyala
Copy link
Member

Use similar approach as UseDiamondOperator, replay inference with a faked expr mirror to
check that replacing lambda with method ref would be valid.

Fix a TODO in type resolution codebase that was causing ambiguity errors with method references.
Potential compatibility of method refs was not checked properly.

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)

Use similar approach as UseDiamondOperator,
replay inference with a faked expr mirror to
check that replacing lambda with method ref
would be valid.

Fix pmd#5043

Fix a TODO in type resolution codebase that was
causing ambiguity errors with method references.
Potential compatibility of method refs was not
checked properly.
@oowekyala oowekyala added this to the 7.20.0 milestone Nov 28, 2025
@oowekyala oowekyala force-pushed the issue5043-lambda-can-be-mref branch from f6ec44f to 18da69c Compare December 1, 2025 10:33
@pmd-actions-helper
Copy link
Contributor

Documentation Preview

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.

Regression Tester Report

(comment created at 2025-12-01 10:52:52+00:00 for 18da69c)

@adangel adangel changed the title [java] Fix FP in LambdaCanBeMethodReference when method ref would be ambiguous [java] Fix #5043: FP in LambdaCanBeMethodReference when method ref would be ambiguous Dec 18, 2025
Copy link
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!

adangel added a commit that referenced this pull request Dec 18, 2025
@adangel adangel merged commit 18da69c into pmd:main Dec 18, 2025
12 checks passed
adangel added a commit that referenced this pull request Dec 18, 2025
@oowekyala oowekyala deleted the issue5043-lambda-can-be-mref branch December 18, 2025 15:57
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 this pull request may close these issues.

[java] LambdaCanBeMethodReference: False positive on overloaded methods

2 participants