Skip to content

Commit

Permalink
Fix NPE in AbstractReturnValueIgnored for lambdas.
Browse files Browse the repository at this point in the history
Fixes #657

RELNOTES: Fixes a null pointer exception in AbstractReturnValueIgnored on expression-type lambdas.

MOE_MIGRATED_REVID=160684735
  • Loading branch information
dfielder authored and cushon committed Jul 1, 2017
1 parent 047d7c6 commit b9b492f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ public class IsLastStatementInBlock<T extends StatementTree> implements Matcher<
public boolean matches(T statement, VisitorState state) {
BlockTree block = state.findEnclosing(BlockTree.class);

return Iterables.getLast(block.getStatements()).equals(statement);
return block != null && Iterables.getLast(block.getStatements()).equals(statement);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
public class ReturnValueIgnoredPositiveCases {
String a = "thing";

// BUG: Diagnostic contains: Return value of this method must be used
private Runnable r = () -> String.valueOf("");

{ // String methods
// BUG: Diagnostic contains: remove this line
String.format("%d", 10);
Expand Down

0 comments on commit b9b492f

Please sign in to comment.