| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 dart2js.typechecker; | 5 library dart2js.typechecker; |
| 6 | 6 |
| 7 import 'common/names.dart' show Identifiers; | 7 import 'common/names.dart' show Identifiers; |
| 8 import 'common/resolution.dart' show Resolution; | 8 import 'common/resolution.dart' show Resolution; |
| 9 import 'common/tasks.dart' show CompilerTask; | 9 import 'common/tasks.dart' show CompilerTask; |
| 10 import 'common.dart'; | 10 import 'common.dart'; |
| (...skipping 1689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1700 if (executableContext.isGenerativeConstructor) { | 1700 if (executableContext.isGenerativeConstructor) { |
| 1701 // The resolver already emitted an error for this expression. | 1701 // The resolver already emitted an error for this expression. |
| 1702 } else { | 1702 } else { |
| 1703 if (currentAsyncMarker == AsyncMarker.ASYNC) { | 1703 if (currentAsyncMarker == AsyncMarker.ASYNC) { |
| 1704 ResolutionInterfaceType futureOfFlattenedType = | 1704 ResolutionInterfaceType futureOfFlattenedType = |
| 1705 commonElements.futureType(types.flatten(expressionType)); | 1705 commonElements.futureType(types.flatten(expressionType)); |
| 1706 expressionType = futureOfFlattenedType; | 1706 expressionType = futureOfFlattenedType; |
| 1707 } | 1707 } |
| 1708 if (expectedReturnType.isVoid && | 1708 if (expectedReturnType.isVoid && |
| 1709 !types.isAssignable(expressionType, const ResolutionVoidType())) { | 1709 !types.isAssignable(expressionType, const ResolutionVoidType())) { |
| 1710 reportTypeWarning(expression, MessageKind.RETURN_VALUE_IN_VOID); | 1710 // In `void f(...) => e`, `e` can have any type. |
| 1711 if (!node.isArrowBody) { |
| 1712 reportTypeWarning(expression, MessageKind.RETURN_VALUE_IN_VOID); |
| 1713 } |
| 1711 } else { | 1714 } else { |
| 1712 checkAssignable(expression, expressionType, expectedReturnType); | 1715 checkAssignable(expression, expressionType, expectedReturnType); |
| 1713 } | 1716 } |
| 1714 } | 1717 } |
| 1715 } else if (currentAsyncMarker != AsyncMarker.SYNC) { | 1718 } else if (currentAsyncMarker != AsyncMarker.SYNC) { |
| 1716 // `return;` is allowed. | 1719 // `return;` is allowed. |
| 1717 } else if (!types.isAssignable( | 1720 } else if (!types.isAssignable( |
| 1718 expectedReturnType, const ResolutionVoidType())) { | 1721 expectedReturnType, const ResolutionVoidType())) { |
| 1719 // Let f be the function immediately enclosing a return statement of the | 1722 // Let f be the function immediately enclosing a return statement of the |
| 1720 // form 'return;' It is a static warning if both of the following | 1723 // form 'return;' It is a static warning if both of the following |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2054 | 2057 |
| 2055 visitTypedef(Typedef node) { | 2058 visitTypedef(Typedef node) { |
| 2056 // Do not typecheck [Typedef] nodes. | 2059 // Do not typecheck [Typedef] nodes. |
| 2057 } | 2060 } |
| 2058 | 2061 |
| 2059 visitNode(Node node) { | 2062 visitNode(Node node) { |
| 2060 reporter.internalError(node, | 2063 reporter.internalError(node, |
| 2061 'Unexpected node ${node.getObjectDescription()} in the type checker.'); | 2064 'Unexpected node ${node.getObjectDescription()} in the type checker.'); |
| 2062 } | 2065 } |
| 2063 } | 2066 } |
| OLD | NEW |