You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CheckReturnValue suggests a fix that causes a non-compilable state for lambda expressions since the variables defined in lambda expressions must be final or effectively final.
I have a naive fix but this would prevent potential fixes for variables defined in lambda expressions.
diff --git a/core/src/main/java/com/google/errorprone/bugpatterns/AbstractReturnValueIgnored.java b/core/src/main/java/com/google/errorprone/bugpatterns/AbstractReturnValueIgnored.java
index d5236902b..0739f866a 100644
--- a/core/src/main/java/com/google/errorprone/bugpatterns/AbstractReturnValueIgnored.java+++ b/core/src/main/java/com/google/errorprone/bugpatterns/AbstractReturnValueIgnored.java@@ -223,12 +223,12 @@ public abstract class AbstractReturnValueIgnored extends BugChecker
Fix fix = SuggestedFix.emptyFix();
Symbol symbol = getSymbol(identifierExpr);
- if (identifierExpr != null- && symbol != null+ if (symbol != null
&& !symbol.name.contentEquals("this")
+ && state.getPath().getParentPath().getLeaf().getKind() != Kind.LAMBDA_EXPRESSION
&& returnType != null
&& state.getTypes().isAssignable(returnType, identifierType)) {
- // Fix by assigning the assigning the result of the call to the root receiver reference.+ // Fix by assigning the result of the call to the root receiver reference.
fix =
SuggestedFix.prefixWith(
methodInvocationTree, state.getSourceForNode(identifierExpr) + " = ");
The text was updated successfully, but these errors were encountered:
CheckReturnValue
suggests a fix that causes a non-compilable state for lambda expressions since the variables defined in lambda expressions must be final or effectively final.You can find a failing test here: PicnicSupermarket@769049b. The test failure:
I have a naive fix but this would prevent potential fixes for variables defined in lambda expressions.
The text was updated successfully, but these errors were encountered: