rewrite-static-analysis icon indicating copy to clipboard operation
rewrite-static-analysis copied to clipboard

`ReplaceLambdaWithMethodReference` should not strip out method invocations

Open timtebeek opened this issue 2 years ago • 0 comments

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

As seen on https://github.com/openrewrite/rewrite-analysis/pull/28

-return Parameter.viewOf(cursor).map(parameter -> (DataFlowNode) new ParameterDataFlowNode(cursor, parameter)).toOption();
+return Parameter.viewOf(cursor).map(DataFlowNode.class::cast).toOption();

While there is indeed a cast, we should not replace if the righthand side of the cast is not simply the same as the left hand side of the lambda.

timtebeek avatar Aug 07 '23 21:08 timtebeek