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

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

Issue 886833005: Fix await parsing. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix metadata_test 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
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 1583 matching lines...) Expand 10 before | Expand all | Expand 10 after
1594 } 1594 }
1595 return const StatementType(); 1595 return const StatementType();
1596 } 1596 }
1597 1597
1598 DartType visitThrow(Throw node) { 1598 DartType visitThrow(Throw node) {
1599 // TODO(johnniwinther): Handle reachability. 1599 // TODO(johnniwinther): Handle reachability.
1600 analyze(node.expression); 1600 analyze(node.expression);
1601 return const DynamicType(); 1601 return const DynamicType();
1602 } 1602 }
1603 1603
1604 DartType flatten(DartType type) {
floitsch 2015/02/03 13:34:21 add comment.
floitsch 2015/02/03 13:34:21 If I understand correctly this reduces the type of
floitsch 2015/02/03 13:34:21 This seems to be very await specific (talking abou
Johnni Winther 2015/02/03 14:12:56 It term 'flatten' is from the spec is used to desc
Johnni Winther 2015/02/03 14:12:56 Done.
1605 if (type is InterfaceType) {
1606 InterfaceType futureType = type.asInstanceOf(compiler.futureClass);
1607 if (futureType != null) {
1608 return flatten(futureType.typeArguments.first);
1609 }
1610 }
1611 return type;
1612 }
1613
1604 DartType visitAwait(Await node) { 1614 DartType visitAwait(Await node) {
1605 DartType expressionType = analyze(node.expression); 1615 DartType expressionType = analyze(node.expression);
1606 DartType resultType = expressionType; 1616 return flatten(expressionType);
1607 if (expressionType is InterfaceType) {
1608 InterfaceType futureType =
1609 expressionType.asInstanceOf(compiler.futureClass);
1610 if (futureType != null) {
1611 resultType = futureType.typeArguments.first;
1612 }
1613 }
1614 return resultType;
1615 } 1617 }
1616 1618
1617 DartType visitYield(Yield node) { 1619 DartType visitYield(Yield node) {
1618 DartType resultType = analyze(node.expression); 1620 DartType resultType = analyze(node.expression);
1619 if (!node.hasStar) { 1621 if (!node.hasStar) {
1620 if (currentAsyncMarker.isAsync) { 1622 if (currentAsyncMarker.isAsync) {
1621 resultType = 1623 resultType =
1622 compiler.streamClass.thisType.createInstantiation( 1624 compiler.streamClass.thisType.createInstantiation(
1623 <DartType>[resultType]); 1625 <DartType>[resultType]);
1624 } else { 1626 } else {
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
1828 1830
1829 visitTypedef(Typedef node) { 1831 visitTypedef(Typedef node) {
1830 // Do not typecheck [Typedef] nodes. 1832 // Do not typecheck [Typedef] nodes.
1831 } 1833 }
1832 1834
1833 visitNode(Node node) { 1835 visitNode(Node node) {
1834 compiler.internalError(node, 1836 compiler.internalError(node,
1835 'Unexpected node ${node.getObjectDescription()} in the type checker.'); 1837 'Unexpected node ${node.getObjectDescription()} in the type checker.');
1836 } 1838 }
1837 } 1839 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698