| 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 part of dart2js; | 5 part of dart2js; |
| 6 | 6 |
| 7 class TypeCheckerTask extends CompilerTask { | 7 class TypeCheckerTask extends CompilerTask { |
| 8 TypeCheckerTask(Compiler compiler) : super(compiler); | 8 TypeCheckerTask(Compiler compiler) : super(compiler); |
| 9 String get name => "Type checker"; | 9 String get name => "Type checker"; |
| 10 | 10 |
| (...skipping 1592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1603 if (currentAsyncMarker == AsyncMarker.ASYNC) { | 1603 if (currentAsyncMarker == AsyncMarker.ASYNC) { |
| 1604 expressionType = coreTypes.futureType(types.flatten(expressionType)); | 1604 expressionType = coreTypes.futureType(types.flatten(expressionType)); |
| 1605 } | 1605 } |
| 1606 if (expectedReturnType.isVoid && | 1606 if (expectedReturnType.isVoid && |
| 1607 !types.isAssignable(expressionType, const VoidType())) { | 1607 !types.isAssignable(expressionType, const VoidType())) { |
| 1608 reportTypeWarning(expression, MessageKind.RETURN_VALUE_IN_VOID); | 1608 reportTypeWarning(expression, MessageKind.RETURN_VALUE_IN_VOID); |
| 1609 } else { | 1609 } else { |
| 1610 checkAssignable(expression, expressionType, expectedReturnType); | 1610 checkAssignable(expression, expressionType, expectedReturnType); |
| 1611 } | 1611 } |
| 1612 } | 1612 } |
| 1613 | 1613 } else if (currentAsyncMarker == AsyncMarker.ASYNC) { |
| 1614 // `return;` is allowed. |
| 1614 } else if (!types.isAssignable(expectedReturnType, const VoidType())) { | 1615 } else if (!types.isAssignable(expectedReturnType, const VoidType())) { |
| 1615 // Let f be the function immediately enclosing a return statement of the | 1616 // Let f be the function immediately enclosing a return statement of the |
| 1616 // form 'return;' It is a static warning if both of the following | 1617 // form 'return;' It is a static warning if both of the following |
| 1617 // conditions hold: | 1618 // conditions hold: |
| 1618 // - f is not a generative constructor. | 1619 // - f is not a generative constructor. |
| 1619 // - The return type of f may not be assigned to void. | 1620 // - The return type of f may not be assigned to void. |
| 1620 reportTypeWarning(node, MessageKind.RETURN_NOTHING, | 1621 reportTypeWarning(node, MessageKind.RETURN_NOTHING, |
| 1621 {'returnType': expectedReturnType}); | 1622 {'returnType': expectedReturnType}); |
| 1622 } | 1623 } |
| 1623 return const StatementType(); | 1624 return const StatementType(); |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1858 | 1859 |
| 1859 visitTypedef(Typedef node) { | 1860 visitTypedef(Typedef node) { |
| 1860 // Do not typecheck [Typedef] nodes. | 1861 // Do not typecheck [Typedef] nodes. |
| 1861 } | 1862 } |
| 1862 | 1863 |
| 1863 visitNode(Node node) { | 1864 visitNode(Node node) { |
| 1864 compiler.internalError(node, | 1865 compiler.internalError(node, |
| 1865 'Unexpected node ${node.getObjectDescription()} in the type checker.'); | 1866 'Unexpected node ${node.getObjectDescription()} in the type checker.'); |
| 1866 } | 1867 } |
| 1867 } | 1868 } |
| OLD | NEW |