openrewrite / rewrite-migrate-java

OpenRewrite recipes for migrating to newer versions of Java.
Apache License 2.0
92 stars 65 forks source link

`LombokValueToRecord` should rewrite method references too #469

Open holgpar opened 2 months ago

holgpar commented 2 months ago

Unfortunately, J.MemberReference does not have a methodType when the member reference is through an object.

When it is throught a class (to a static method) it works as expected...

What's changed?

What's your motivation?

Anything in particular you'd like reviewers to focus on?

Anyone you would like to review specifically?

Have you considered any alternatives or workarounds?

Any additional context

Checklist

knutwannheden commented 2 months ago

That there isn't any method type in that case sounds like a bug in the Java parser to me.

timtebeek commented 2 months ago

Can we separate these cases into separate tests to get these changes partially through already? Then we can separately work on the type issues, with the failing test here marked as @ExpectedToFail.

holgpar commented 2 months ago

hm... at the moment we cannot do a meaningful implementation that addresses method references. So are you asking for a test case to reproduce the issue?

timtebeek commented 2 months ago

Ah no I'd thought from your message above that it does work for ClassName::methodName, but not for someInstance::methodName, and as such that we can at the very least try to cover the first case already, and add a separate unit test for the second case annotated with @ExpectedToFail (or @Disabled). If I misunderstood then please ignore; we'll need that proper fix anyway as well.

holgpar commented 2 months ago

I just mentioned the static case to give you guys a clue on what might be wrong... It does not help for this recipe. Sorry for causing confusion.