| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 // TODO(jmesserly): this was ported from package:dev_compiler, and needs to be | 5 // TODO(jmesserly): this was ported from package:dev_compiler, and needs to be |
| 6 // refactored to fit into analyzer. | 6 // refactored to fit into analyzer. |
| 7 library analyzer.src.task.strong.checker; | 7 library analyzer.src.task.strong.checker; |
| 8 | 8 |
| 9 import 'package:analyzer/analyzer.dart'; | 9 import 'package:analyzer/analyzer.dart'; |
| 10 import 'package:analyzer/src/generated/ast.dart'; | 10 import 'package:analyzer/src/generated/ast.dart'; |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 {bool yieldStar: false}) { | 607 {bool yieldStar: false}) { |
| 608 var body = node.getAncestor((n) => n is FunctionBody); | 608 var body = node.getAncestor((n) => n is FunctionBody); |
| 609 var type = rules.getExpectedReturnType(body, yieldStar: yieldStar); | 609 var type = rules.getExpectedReturnType(body, yieldStar: yieldStar); |
| 610 if (type == null) { | 610 if (type == null) { |
| 611 // We have a type mismatch: the async/async*/sync* modifier does | 611 // We have a type mismatch: the async/async*/sync* modifier does |
| 612 // not match the return or yield type. We should have already gotten an | 612 // not match the return or yield type. We should have already gotten an |
| 613 // analyzer error in this case. | 613 // analyzer error in this case. |
| 614 return; | 614 return; |
| 615 } | 615 } |
| 616 InterfaceType futureType = rules.provider.futureType; | 616 InterfaceType futureType = rules.provider.futureType; |
| 617 DartType actualType = expression.staticType; | 617 DartType actualType = expression?.staticType; |
| 618 if (body.isAsynchronous && | 618 if (body.isAsynchronous && |
| 619 !body.isGenerator && | 619 !body.isGenerator && |
| 620 actualType is InterfaceType && | 620 actualType is InterfaceType && |
| 621 actualType.element == futureType.element) { | 621 actualType.element == futureType.element) { |
| 622 type = futureType.substitute4([type]); | 622 type = futureType.substitute4([type]); |
| 623 } | 623 } |
| 624 // TODO(vsm): Enforce void or dynamic (to void?) when expression is null. | 624 // TODO(vsm): Enforce void or dynamic (to void?) when expression is null. |
| 625 if (expression != null) checkAssignment(expression, type); | 625 if (expression != null) checkAssignment(expression, type); |
| 626 } | 626 } |
| 627 | 627 |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1050 } | 1050 } |
| 1051 } catch (e) { | 1051 } catch (e) { |
| 1052 // TODO(sigmund): remove this try-catch block (see issue #48). | 1052 // TODO(sigmund): remove this try-catch block (see issue #48). |
| 1053 } | 1053 } |
| 1054 if (baseMethod == null || baseMethod.isStatic) return null; | 1054 if (baseMethod == null || baseMethod.isStatic) return null; |
| 1055 return baseMethod.type; | 1055 return baseMethod.type; |
| 1056 } | 1056 } |
| 1057 ; | 1057 ; |
| 1058 return f; | 1058 return f; |
| 1059 } | 1059 } |
| OLD | NEW |