Skip to content
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

Incorrect LambdaMethodReference error-prone warning #772

Closed
dtobin opened this issue Aug 23, 2019 · 4 comments
Closed

Incorrect LambdaMethodReference error-prone warning #772

dtobin opened this issue Aug 23, 2019 · 4 comments

Comments

@dtobin
Copy link
Contributor

dtobin commented Aug 23, 2019

What happened?

Lambda expression:

() -> foo.getBar().baz()

Warning printed:

Note: [LambdaMethodReference] Lambda should be a method reference

version: gradle-baseline-java 1.16.0

What did you want to happen?

No warning printed. Unless I'm missing something, I don't see a way to convert this expression to a method reference. This would be functionally not equivalent:

foo.getBar()::baz
@carterkozak
Copy link
Contributor

Have you seen #771

@dtobin
Copy link
Contributor Author

dtobin commented Aug 23, 2019

Ah! Requiring static methods will fix this issue, though is there any reason we would want to rewrite (or suggest a rewrite for) chained method calls in a lambda at all?

@carterkozak
Copy link
Contributor

Nope, chained method invocations cannot result in a static method invocation.

@dtobin
Copy link
Contributor Author

dtobin commented Aug 23, 2019

I guess a better phrasing of my question is why were chained method invocations considered in the first place (before the switch to only allowing static method invocations), and should we add an additional check to the code to immediately return on chained method invocations, in case you eventually revert the static method restriction? In any case, this issue will be fixed by #771, no additional work required.

@dtobin dtobin closed this as completed Aug 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants