Closed moderne-meeseeks[bot] closed 9 months ago
This comment originially written by @ on:
This is surprisingly tricky to solve and some of the internals make it even harder than it should be.
I'm having a similar problem. When solving this problem I'm hoping it can be solved in a generic way and that in some cases the ambiguity can be solved without having to resort to the kill solution of 'don't convert to Lamba'. We are using the Wicket framework and there are lots of places where 6-7 lines can be changed into a single Lambda which is superb. Most of the times this works but sometimes it doesn't work. It always goes wrong with CssClassNameAppender. I'm really hoping that there is a way to solve this ambiguity by looking at the context or something like that. If needed I can create a separate ticket for it.
As mentioned earlier this recipe caused problems for my IDB repo as well. Had to exclude files for it. Re tested all excluded files. The new version of the recipe now handles it correctly. As in no compiling errors any longer.
Problem
Ambiguity as there's two methods that match the use of the lambda here:
Expected behavior
Not converted to lambda, as there's ambiguity,
Example diff
From:
src/main/java/com/github/tomakehurst/wiremock/common/xml/Xml.java
Recipes in example diff:
org.openrewrite.java.cleanup.UseLambdaForFunctionalInterface
References:
org.openrewrite.java.cleanup.UseLambdaForFunctionalInterface
Use lambdas where possible
wiremock/wiremock/master
This issue originally created by @timtebeek on: https://github.com/moderneinc/support-public/issues/35