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

Unified Diff: pkg/analyzer/lib/src/generated/resolver.dart

Issue 2630023003: Report HintCode.MISSING_RETURN for async functions with return type that matters. (Closed)
Patch Set: Created 3 years, 11 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: pkg/analyzer/lib/src/generated/resolver.dart
diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
index 43146a226bfaa36c4155154194b0ae57d90e80b6..5f0397fd8a6424039f2cd424581c57ce9f726570 100644
--- a/pkg/analyzer/lib/src/generated/resolver.dart
+++ b/pkg/analyzer/lib/src/generated/resolver.dart
@@ -900,11 +900,19 @@ class BestPracticesVerifier extends RecursiveAstVisitor<Object> {
if (returnTypeType == null || returnTypeType.isVoid) {
return;
}
- // For async, give no hint if Future<Null> is assignable to the return
- // type.
- if (body.isAsynchronous &&
- _typeSystem.isAssignableTo(_futureNullType, returnTypeType)) {
- return;
+ // For async, give no hint if the return type does not matter, i.e.
+ // dynamic, Future<Null> or Future<dynamic>.
+ if (body.isAsynchronous) {
+ if (returnTypeType.isDynamic) {
+ return;
+ }
+ if (returnTypeType is InterfaceType &&
+ returnTypeType.isDartAsyncFuture) {
+ DartType futureArgument = returnTypeType.typeArguments[0];
+ if (futureArgument.isDynamic || futureArgument.isDartCoreNull) {
+ return;
+ }
+ }
}
// Check the block for a return statement, if not, create the hint
if (!ExitDetector.exits(body)) {

Powered by Google App Engine
This is Rietveld 408576698