Cast when needed on lambda expressions #207
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What's changed?
We need to cast the lambda expression, when we have some unbounded generics on it's body. Right now I'm trying to identify those by searching for method invocations of methods with arguments with parametrized types with generics, but this just narrows it a bit, but those generics not necessarily are unbounded without the explicit cast.
Also, changed the
methodArgumentRequiresCastand previous check to accept MethodCall instead ofJ.MethodInvocation, so we can also reuse it forJ.NewClasstooWhat's your motivation?
Fixes https://github.com/moderneinc/support-app/issues/17
Anything in particular you'd like reviewers to focus on?
How we can detect better when it's needed to add the cast and when it's redundant?
Checklist