Skip to content

Fix ExtensionMethod target typing for poly expressions in Eclipse - #4036

Open
z-xhh wants to merge 1 commit into
projectlombok:masterfrom
z-xhh:feature/extensionmethod-poly-binding
Open

Fix ExtensionMethod target typing for poly expressions in Eclipse#4036
z-xhh wants to merge 1 commit into
projectlombok:masterfrom
z-xhh:feature/extensionmethod-poly-binding

Conversation

@z-xhh

@z-xhh z-xhh commented Apr 10, 2026

Copy link
Copy Markdown

Summary

This change fixes Eclipse @ExtensionMethod resolution when an argument is a poly expression that already carries an overly broad resolved type.

In the failing case, a call like:

order.canRefund(Collections.emptyList())

could be treated as passing List<Object> instead of List<RefundOrderDto>. That caused extension method resolution to fail before the call could be rewritten to the static extension method form.

What Changed

  • Prefer PolyTypeBinding for poly-expression arguments in the Eclipse extension-method resolution path, instead of only doing so when resolvedType is null.
  • Add a regression test covering extension-method target typing with an empty generic list argument.
  • Use Collections.emptyList() in the regression test so the case stays valid on the ECJ test path and isolates the actual inference issue.

Why This Matters

Without this change, valid extension-method calls can be rejected in Eclipse/JDT because argument typing is finalized too early and loses the target type required by the extension method signature.

Repro

Given an extension method like:

public static boolean canRefund(OrderDto order, List<RefundOrderDto> refunds)

a call such as:

order.canRefund(Collections.emptyList())

could fail in Eclipse/JDT with an error equivalent to:

The method canRefund(OrderDto, List<RefundOrderDto>) is not applicable for the arguments (OrderDto, List<Object>)

Validation

  • dist test.eclipse-202503
  • test.compile

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.

2 participants