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

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

Issue 895583006: Update yield warnings. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 5 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « pkg/compiler/lib/src/resolution/signatures.dart ('k') | pkg/compiler/lib/src/warnings.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 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 1611 matching lines...) Expand 10 before | Expand all | Expand 10 after
1622 1622
1623 DartType visitAwait(Await node) { 1623 DartType visitAwait(Await node) {
1624 DartType expressionType = analyze(node.expression); 1624 DartType expressionType = analyze(node.expression);
1625 return flatten(expressionType); 1625 return flatten(expressionType);
1626 } 1626 }
1627 1627
1628 DartType visitYield(Yield node) { 1628 DartType visitYield(Yield node) {
1629 DartType resultType = analyze(node.expression); 1629 DartType resultType = analyze(node.expression);
1630 if (!node.hasStar) { 1630 if (!node.hasStar) {
1631 if (currentAsyncMarker.isAsync) { 1631 if (currentAsyncMarker.isAsync) {
1632 resultType = 1632 resultType = compiler.coreTypes.streamType(resultType);
1633 compiler.streamClass.thisType.createInstantiation(
1634 <DartType>[resultType]);
1635 } else { 1633 } else {
1636 resultType = 1634 resultType = compiler.coreTypes.iterableType(resultType);
1637 compiler.iterableClass.thisType.createInstantiation( 1635 }
1638 <DartType>[resultType]); 1636 } else {
1637 if (currentAsyncMarker.isAsync) {
1638 // The static type of expression must be assignable to Stream.
1639 checkAssignable(node, resultType, compiler.coreTypes.streamType());
1640 } else {
1641 // The static type of expression must be assignable to Iterable.
1642 checkAssignable(node, resultType, compiler.coreTypes.iterableType());
1639 } 1643 }
1640 } 1644 }
1645 // The static type of the result must be assignable to the declared type.
1641 checkAssignable(node, resultType, expectedReturnType); 1646 checkAssignable(node, resultType, expectedReturnType);
1642 return const StatementType(); 1647 return const StatementType();
1643 } 1648 }
1644 1649
1645 DartType visitTypeAnnotation(TypeAnnotation node) { 1650 DartType visitTypeAnnotation(TypeAnnotation node) {
1646 return elements.getType(node); 1651 return elements.getType(node);
1647 } 1652 }
1648 1653
1649 DartType visitVariableDefinitions(VariableDefinitions node) { 1654 DartType visitVariableDefinitions(VariableDefinitions node) {
1650 DartType type = analyzeWithDefault(node.type, const DynamicType()); 1655 DartType type = analyzeWithDefault(node.type, const DynamicType());
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1839 1844
1840 visitTypedef(Typedef node) { 1845 visitTypedef(Typedef node) {
1841 // Do not typecheck [Typedef] nodes. 1846 // Do not typecheck [Typedef] nodes.
1842 } 1847 }
1843 1848
1844 visitNode(Node node) { 1849 visitNode(Node node) {
1845 compiler.internalError(node, 1850 compiler.internalError(node,
1846 'Unexpected node ${node.getObjectDescription()} in the type checker.'); 1851 'Unexpected node ${node.getObjectDescription()} in the type checker.');
1847 } 1852 }
1848 } 1853 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/resolution/signatures.dart ('k') | pkg/compiler/lib/src/warnings.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698