Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1292)

Unified Diff: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/hint/BestPracticesVerifier.java

Issue 913623002: Partial backport of analyzer async/await fixes to Java. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix status files Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/hint/BestPracticesVerifier.java
diff --git a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/hint/BestPracticesVerifier.java b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/hint/BestPracticesVerifier.java
index d9aae72bd69ff26d21db1adad4134f610faf837e..d951681bd8dc2e652a09e0214278b02694bea533 100644
--- a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/hint/BestPracticesVerifier.java
+++ b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/hint/BestPracticesVerifier.java
@@ -577,7 +577,9 @@ public class BestPracticesVerifier extends RecursiveAstVisitor<Void> {
/**
* Generate a hint for functions or methods that have a return type, but do not have a return
* statement on all branches. At the end of blocks with no return, Dart implicitly returns
- * {@code null}, avoiding these implicit returns is considered a best practice.
+ * {@code null}, avoiding these implicit returns is considered a best practice. Note: for async
+ * functions/methods, this hint only applies when the function has a return type that
+ * Future&lt;Null&gt; is not assignable to.
*
* @param node the binary expression to check
* @param body the function body
@@ -595,12 +597,25 @@ public class BestPracticesVerifier extends RecursiveAstVisitor<Void> {
return false;
}
+ // Generators are never required to have a return statement.
+ if (body.isGenerator()) {
+ return false;
+ }
+
// Check that the type is resolvable, and is not "void"
Type returnTypeType = returnType.getType();
if (returnTypeType == null || returnTypeType.isVoid()) {
return false;
}
+ // For async, give no hint if Future<Null> is assignable to the return type.
+ // TODO(paulberry): we can't check if Future<Null> is assignable to the return type because the
+ // Future type isn't available in the type provider. So to avoid bogus hints, just suppress
+ // the hint for asynchronous methods.
+ if (body.isAsynchronous()) {
+ return false;
+ }
+
// Check the block for a return statement, if not, create the hint
BlockFunctionBody blockFunctionBody = (BlockFunctionBody) body;
if (!blockFunctionBody.accept(new ExitDetector())) {

Powered by Google App Engine
This is Rietveld 408576698