-
Notifications
You must be signed in to change notification settings - Fork 86
LombokValueToRecord
should rewrite method references too
#469
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
base: main
Are you sure you want to change the base?
Conversation
That there isn't any method type in that case sounds like a bug in the Java parser to me. |
LombokValueToRecord
should rewrite method references too
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 |
hm... at the moment we cannot do a meaningful implementation that addresses method references. |
Ah no I'd thought from your message above that it does work for |
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. |
Let's see if the tests pass and if so we can merge this addition to the recipe. 🙏🏻 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some suggestions could not be made:
- src/test/java/org/openrewrite/java/migrate/lombok/LombokValueToRecordTest.java
- lines 27-28
if(recordTypeToMembers.containsKey(classFqn) | ||
&& recordTypeToMembers.get(classFqn).contains(getterMethodNameToFluentMethodName(methodName)) | ||
&& methodName.startsWith(STANDARD_GETTER_PREFIX)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if(recordTypeToMembers.containsKey(classFqn) | |
&& recordTypeToMembers.get(classFqn).contains(getterMethodNameToFluentMethodName(methodName)) | |
&& methodName.startsWith(STANDARD_GETTER_PREFIX)) { | |
if(recordTypeToMembers.containsKey(classFqn) && | |
recordTypeToMembers.get(classFqn).contains(getterMethodNameToFluentMethodName(methodName)) && | |
methodName.startsWith(STANDARD_GETTER_PREFIX)) { |
This now fails with
diff --git a/example/A.java b/example/A.java
index 044b9dd..f63ce43 100644
--- a/example/A.java
+++ b/example/A.java
@@ -4,13 +4,23 @@
public record A(
String test) {
+
+}
+
+class B {
+
+
+ public static String classMethod() {
+ return "foo";
+ }
+
}
class Using {
Supplier<String> usingMethodReference() {
A a = new A("foo");
- return a::test;
+ return a::getTest;
}
}
\ No newline at end of file |
Unfortunately,
J.MemberReference
does not have a methodType whenthe 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