| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library analyzer.src.generated.resolver; | 5 library analyzer.src.generated.resolver; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
| 10 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; | 10 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; |
| (...skipping 882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 893 if (body is BlockFunctionBody) { | 893 if (body is BlockFunctionBody) { |
| 894 // Generators are never required to have a return statement. | 894 // Generators are never required to have a return statement. |
| 895 if (body.isGenerator) { | 895 if (body.isGenerator) { |
| 896 return; | 896 return; |
| 897 } | 897 } |
| 898 // Check that the type is resolvable, and is not "void" | 898 // Check that the type is resolvable, and is not "void" |
| 899 DartType returnTypeType = returnType.type; | 899 DartType returnTypeType = returnType.type; |
| 900 if (returnTypeType == null || returnTypeType.isVoid) { | 900 if (returnTypeType == null || returnTypeType.isVoid) { |
| 901 return; | 901 return; |
| 902 } | 902 } |
| 903 // For async, give no hint if Future<Null> is assignable to the return | 903 // For async, give no hint if the return type does not matter, i.e. |
| 904 // type. | 904 // dynamic, Future<Null> or Future<dynamic>. |
| 905 if (body.isAsynchronous && | 905 if (body.isAsynchronous) { |
| 906 _typeSystem.isAssignableTo(_futureNullType, returnTypeType)) { | 906 if (returnTypeType.isDynamic) { |
| 907 return; | 907 return; |
| 908 } |
| 909 if (returnTypeType is InterfaceType && |
| 910 returnTypeType.isDartAsyncFuture) { |
| 911 DartType futureArgument = returnTypeType.typeArguments[0]; |
| 912 if (futureArgument.isDynamic || futureArgument.isDartCoreNull) { |
| 913 return; |
| 914 } |
| 915 } |
| 908 } | 916 } |
| 909 // Check the block for a return statement, if not, create the hint | 917 // Check the block for a return statement, if not, create the hint |
| 910 if (!ExitDetector.exits(body)) { | 918 if (!ExitDetector.exits(body)) { |
| 911 _errorReporter.reportErrorForNode( | 919 _errorReporter.reportErrorForNode( |
| 912 HintCode.MISSING_RETURN, returnType, [returnTypeType.displayName]); | 920 HintCode.MISSING_RETURN, returnType, [returnTypeType.displayName]); |
| 913 } | 921 } |
| 914 } | 922 } |
| 915 } | 923 } |
| 916 | 924 |
| 917 /** | 925 /** |
| (...skipping 9896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10814 return null; | 10822 return null; |
| 10815 } | 10823 } |
| 10816 if (identical(node.staticElement, variable)) { | 10824 if (identical(node.staticElement, variable)) { |
| 10817 if (node.inSetterContext()) { | 10825 if (node.inSetterContext()) { |
| 10818 result = true; | 10826 result = true; |
| 10819 } | 10827 } |
| 10820 } | 10828 } |
| 10821 return null; | 10829 return null; |
| 10822 } | 10830 } |
| 10823 } | 10831 } |
| OLD | NEW |