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

LombokValueToRecord results in broken if method references are used #449

Open
holgpar opened this issue Apr 2, 2024 · 3 comments
Open
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@holgpar
Copy link
Contributor

holgpar commented Apr 2, 2024

What version of OpenRewrite are you using?

  • OpenRewrite v1.2.3
  • Maven/Gradle plugin v1.2.3
  • rewrite-module v1.2.3

How are you running OpenRewrite?

From the sources of rewrite-migrate-java.

What is the smallest, simplest way to reproduce the problem?

The recipe correctly adapts method invocations to the changed getter naming convention: getTest() -> test(). But it does not do so for method references, i.e. a::getTest remains as it is.

Are you interested in contributing a fix to OpenRewrite?

Yes, I would like to, but could you elaborate on how openrewrite models method references? Is it some kind of member reference?

@holgpar holgpar added the bug Something isn't working label Apr 2, 2024
@knutwannheden
Copy link
Contributor

Yes, I would like to, but could you elaborate on how openrewrite models method references? Is it some kind of member reference?

Correct. There is a J.MemberReference type, which in case it is a reference to a method has a non-null methodType: https://github.com/openrewrite/rewrite/blob/516c70b89ebbb43803d2dd6e0bc2cf31307a80d3/rewrite-java/src/main/java/org/openrewrite/java/tree/J.java#L3454-L3460. This methodType is the type attribution for the method the method reference refers to.

Hope this helps!

@holgpar
Copy link
Contributor Author

holgpar commented Apr 3, 2024

Hope this helps!

yes! I will look into it after my vacation.

@timtebeek timtebeek added the good first issue Good for newcomers label Apr 30, 2024
@holgpar
Copy link
Contributor Author

holgpar commented May 1, 2024

I tried to implement it, but I encountered an issue. which is demonstrated here:

For a member reference a::getTest the field methodType is null.
It works however for static methods...

Any ideas @knutwannheden @timtebeek ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
Status: Backlog
Development

No branches or pull requests

3 participants