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

Side by Side Diff: pkg/compiler/lib/src/typechecker.dart

Issue 1367433002: Avoid warning when using `return;` from sync* and async* functions. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fix mock_libraries modification Created 5 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | tests/compiler/dart2js/mock_libraries.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 7 import 'common/names.dart' show
8 Identifiers; 8 Identifiers;
9 import 'common/tasks.dart' show 9 import 'common/tasks.dart' show
10 CompilerTask; 10 CompilerTask;
(...skipping 1637 matching lines...) Expand 10 before | Expand all | Expand 10 after
1648 if (currentAsyncMarker == AsyncMarker.ASYNC) { 1648 if (currentAsyncMarker == AsyncMarker.ASYNC) {
1649 expressionType = coreTypes.futureType(types.flatten(expressionType)); 1649 expressionType = coreTypes.futureType(types.flatten(expressionType));
1650 } 1650 }
1651 if (expectedReturnType.isVoid && 1651 if (expectedReturnType.isVoid &&
1652 !types.isAssignable(expressionType, const VoidType())) { 1652 !types.isAssignable(expressionType, const VoidType())) {
1653 reportTypeWarning(expression, MessageKind.RETURN_VALUE_IN_VOID); 1653 reportTypeWarning(expression, MessageKind.RETURN_VALUE_IN_VOID);
1654 } else { 1654 } else {
1655 checkAssignable(expression, expressionType, expectedReturnType); 1655 checkAssignable(expression, expressionType, expectedReturnType);
1656 } 1656 }
1657 } 1657 }
1658 } else if (currentAsyncMarker == AsyncMarker.ASYNC) { 1658 } else if (currentAsyncMarker != AsyncMarker.SYNC) {
1659 // `return;` is allowed. 1659 // `return;` is allowed.
1660 } else if (!types.isAssignable(expectedReturnType, const VoidType())) { 1660 } else if (!types.isAssignable(expectedReturnType, const VoidType())) {
1661 // Let f be the function immediately enclosing a return statement of the 1661 // Let f be the function immediately enclosing a return statement of the
1662 // form 'return;' It is a static warning if both of the following 1662 // form 'return;' It is a static warning if both of the following
1663 // conditions hold: 1663 // conditions hold:
1664 // - f is not a generative constructor. 1664 // - f is not a generative constructor.
1665 // - The return type of f may not be assigned to void. 1665 // - The return type of f may not be assigned to void.
1666 reportTypeWarning(node, MessageKind.RETURN_NOTHING, 1666 reportTypeWarning(node, MessageKind.RETURN_NOTHING,
1667 {'returnType': expectedReturnType}); 1667 {'returnType': expectedReturnType});
1668 } 1668 }
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
1957 1957
1958 visitTypedef(Typedef node) { 1958 visitTypedef(Typedef node) {
1959 // Do not typecheck [Typedef] nodes. 1959 // Do not typecheck [Typedef] nodes.
1960 } 1960 }
1961 1961
1962 visitNode(Node node) { 1962 visitNode(Node node) {
1963 compiler.internalError(node, 1963 compiler.internalError(node,
1964 'Unexpected node ${node.getObjectDescription()} in the type checker.'); 1964 'Unexpected node ${node.getObjectDescription()} in the type checker.');
1965 } 1965 }
1966 } 1966 }
OLDNEW
« no previous file with comments | « no previous file | tests/compiler/dart2js/mock_libraries.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698