rewrite-migrate-java icon indicating copy to clipboard operation
rewrite-migrate-java copied to clipboard

`LombokValueToRecord` should rewrite method references too

Open holgpar opened this issue 10 months ago • 5 comments

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

  • [ ] I've added unit tests to cover both positive and negative cases
  • [ ] I've read and applied the recipe conventions and best practices
  • [ ] I've used the IntelliJ IDEA auto-formatter on affected files

holgpar avatar May 01 '24 13:05 holgpar

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

knutwannheden avatar May 01 '24 15:05 knutwannheden

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.

timtebeek avatar May 02 '24 11:05 timtebeek

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?

holgpar avatar May 02 '24 12:05 holgpar

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.

timtebeek avatar May 02 '24 12:05 timtebeek

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.

holgpar avatar May 02 '24 12:05 holgpar